开发者

NSTextView incorrectly displaying text from an attributed string based upon HTML

开发者 https://www.devze.com 2023-04-09 12:29 出处:网络
I have the following text - ❶can be added as The above text shows up fine in Text Edit. But when I try displaying the same in NSTextView, I get strange characters -

I have the following text -

❶can be added as

The above text shows up fine in Text Edit. But when I try displaying the same in NSTextView, I get strange characters -

â¶can be added as

The foll开发者_如何转开发owing is the code that I am using to display the text in NSTextView

NSURL *url = < base URL >;
NSAttributedString *attrString = [[NSAttributedString alloc]
    initWithHTML: data baseURL: url documentAttributes: (NSDictionary **) NULL];
[[textView textStorage] setAttributedString: attrString];
[attrString release];

data is set as -

data = NSData.FromString ("<html><head><style>p {font-size:14px;}</style></head><body><p>❶can be added </p></body></html>");
0

精彩评论

暂无评论...
验证码 换一张
取 消