我有一些文字格式问题需要解决。我有一些奇怪的字符从NSString的下方显示如何正确编码一些文本
原始字符串:
NSString *descriptionStringPreFormatted = [item objectForKey:@"title"];
格式的字符串:
NSString *descriptionLabelStringUTF8 = [descriptionStringPreFormatted stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSLog(@"descriptionStringPreFormatted is %@", descriptionStringPreFormatted);
NSLog(@"descriptionLabelStringUTF8 is %@", descriptionLabelStringUTF8);
这里的输出是同我是否使用UTF8编码或不。
输出:
2013-01-05 16:44:51.807 descriptionStringPreFormatted is £144.99...
2013-01-05 16:44:51.810 descriptionLabelStringUTF8 is £144.99...
你期望字符串是什么?另外我相信NSString会将字符串数据默认存储为utf8 –
某些字符串显示为:“144.99 ...”而不是“144.99英镑......”注意£符号的“infront”。我得到的字符串来源显示为“£144.99 ...”,所以我不知道发生了什么 – hanumanDev
你是如何创建字符串? –