hide
我想将所有unicode从上面的字符串转换为字符串。
答案 0 :(得分:0)
我们的项目中有以下方法:
- (NSString *)convertHTMLToUnicode {
NSArray *theHTMLEntities = @[@"&", @"Ä", /* more stuff */];
NSArray *theUnicodeEntities = @[@"&", @"Ä", /* more stuff */];
NSDictionary *theHTMLSource = [NSDictionary dictionaryWithObjects:theUnicodeEntities forKeys:theHTMLEntities];
NSMutableString *theText = [NSMutableString stringWithString:self];
for (NSString *theHtml in theHTMLEntities) {
[theText replaceOccurrencesOfString:theHtml
withString:[theHTMLSource valueForKey:theHtml]
options:NSLiteralSearch
range:NSMakeRange(0, theText.length)];
}
return theText;
}