NSTextView根据HTML错误地显示来自属性字符串的文本

时间:2011-10-01 01:48:12

标签: objective-c cocoa

我有以下文字 -

❶可以添加为

以上文字在文字编辑中显示正常。但是当我尝试在NSTextView中显示相同内容时,我会得到奇怪的字符 -

可以添加为

以下是我用来在NSTextView

中显示文本的代码
NSURL *url = < base URL >;
NSAttributedString *attrString = [[NSAttributedString alloc]
    initWithHTML: data baseURL: url documentAttributes: (NSDictionary **) NULL];
[[textView textStorage] setAttributedString: attrString];
[attrString release];

数据设置为 -

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

0 个答案:

没有答案