简体   繁体   English

如何从ios中的字符串中删除unicode?

[英]How to remove unicode from the string in ios?

    @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. 该字符串通过JSON API传递给应用程序。 The above code eliminated the HTML tags and escape sequences but unicode still remains. 上面的代码消除了HTML标记和转义序列,但unicode仍然保留。

Try this, 尝试这个,

-[NSString dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES] -[NSString dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM