>
> On 22 May '08, at 8:42 PM, [EMAIL PROTECTED] wrote:
>
>> [str initWithString:[self messageField]];
>
> Well, that's the problem. You initialized the attributed string from a
> plain string, which means it gets no formatting.
>
> If your text is in an NSTextField, call -attributedStringValue on it
> to get the text with styles.
>
> —Jens
I hope you could understand my question,

I've a Textview  contains the string

"Sample mail   bold italic

a<b.

Itdoesn't convert bold italic underline."



I can convert it to

<html>
<head>
<title>Sample</title>
</head>
<body>
<font face="Helvetica" size="3">Sample mail &nbsp; bold italic
&nbsp;</font><br>
<font face="Helvetica" size="3"></font><br>
<font face="Helvetica" size="3">a&lt;b.&nbsp;</font><br>
<font face="Helvetica" size="3"></font><br>
<font face="Helvetica" size="3">Itdoesn't convert bold italic
underline.</font>
</body>
</html>

by using the code
 NSAttributedString * str =  [[NSAttributedString alloc]init];
 [str initWithString:[self messageField]];//where messageField gives string.
  NSString * aTitle = @"Sample";
  NSArray*        excluded = [NSArray arrayWithObjects:
@"doctype",@"p",@"meta",@"xml",@"span",  nil];
  NSDictionary*    attr = [NSDictionary dictionaryWithObjectsAndKeys:
                          NSHTMLTextDocumentType,
NSDocumentTypeDocumentAttribute,
                          aTitle, NSTitleDocumentAttribute,excluded,
NSExcludedElementsDocumentAttribute,
                          [NSNumber numberWithInt: NSASCIIStringEncoding],
                          NSCharacterEncodingDocumentAttribute,nil];
  NSData*        tData = [str dataFromRange: NSMakeRange(0, [str length])
documentAttributes: attr error: nil];
  NSString * fileContents=[[NSString alloc] initWithData:tData
                                        encoding:NSNEXTSTEPStringEncoding];
        [htmlView setString:fileContents];//htmlView is textview.

but doesnot gives <b>,<i> or colour tags corresponding to the values.

_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to