@property (weak, nonatomic) IBOutlet UITextView *descriptionText;
NSAttributedString *attributedString = [[NSAttributedString alloc] initWithData:
[htmlString dataUsingEncoding:NSUnicodeStringEncoding]
options:@{
NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType
} documentAttributes:nil error:nil];
descriptionText.attributedText=attributedString;
The string is passed to the application through a JSON API. The above code eliminated the HTML tags and escape sequences but unicode still remains.
Try this,
-[NSString dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.