string to html.

  • hi,

    I've to convert text or image to its corresponding html code.
    i've done

    setContentType: @"text/html";
    setContentTransferEncoding:None;
    setCharset: @"us-ascii"

    NSDictionary*    attr = [NSDictionary
    dictionaryWithObject:NSHTMLTextDocumentType
    forKey:NSDocumentTypeDocumentAttribute];

    NSAttributedString*    textValue = [[NSAttributedString alloc]
    initWithString: [self messageField]];//where messageField returns string.
    NSData*        tData = [textValue dataFromRange: NSMakeRange(0, [[self
    messageField] length])
                            documentAttributes: attr error: nil];

    tData still giving the text value not it scoresponding html code.So is it
    right way?or Am i mis anything here?Anybody can help me?

    Thanks
  • On 16 May '08, at 3:42 AM, <vinitha...> wrote:

    > NSAttributedString*    textValue = [[NSAttributedString alloc]
    > initWithString: [self messageField]];//where messageField returns
    > string.

    That's going to produce an attributed string with no text styles at
    all, because all you gave it was a plain NSString. So I would expect
    that the HTML returned would look mostly like the original text
    (unless it includes "<" or "&".)

    Were you intending to use styled text?

    —Jens
previous month may 2008 next month
MTWTFSS
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31  
Go to today