我在我的应用程序中使用此代码。刚比较韩语时发现不正确
for (NSString *lang in array){
NSString *currentLang = [[MLLanguage sharedInstance] lang];
BOOL flag = [lang isEqualToString:currentLang];
NSLog(@"\n'%@' isEqual to '%@', %d\n%@\n%@", lang, currentLang, flag?1:0, [lang dataUsingEncoding:NSUTF8StringEncoding], [currentLang dataUsingEncoding:NSUTF8StringEncoding]);
错误结果:两个韩语单词比较不同
2012-06-19 21:16:52.681 Motilink[10188:11903] -[MLSettingLanguageViewController loadDownloadedData][Line 50]
'English' isEqual to '한국어', 0
<456e676c 697368>
<ed959cea b5adec96 b4>
2012-06-19 21:16:52.682 Motilink[10188:11903] -[MLSettingLanguageViewController loadDownloadedData][Line 50]
'한국어' isEqual to '한국어', 0
<e18492e1 85a1e186 abe18480 e185aee1 86a8e184 8be185a5>
<ed959cea b5adec96 b4>
2012-06-19 21:16:52.682 Motilink[10188:11903] -[MLSettingLanguageViewController loadDownloadedData][Line 50]
'中国语' isEqual to '한국어', 0
<e4b8ade5 9bbde8af ad>
<ed959cea b5adec96 b4>
正确一个:
2012-06-19 21:35:00.908 Motilink[10188:11903] -[MLSettingLanguageViewController loadDownloadedData][Line 50]
'English' isEqual to '中国语', 0
<456e676c 697368>
<e4b8ade5 9bbde8af ad>
2012-06-19 21:35:00.909 Motilink[10188:11903] -[MLSettingLanguageViewController loadDownloadedData][Line 50]
'한국어' isEqual to '中国语', 0
<e18492e1 85a1e186 abe18480 e185aee1 86a8e184 8be185a5>
<e4b8ade5 9bbde8af ad>
2012-06-19 21:35:00.909 Motilink[10188:11903] -[MLSettingLanguageViewController loadDownloadedData][Line 50]
'中国语' isEqual to '中国语', 1
<e4b8ade5 9bbde8af ad>
<e4b8ade5 9bbde8af ad>
似乎: NSString 自己使用编码,
英语只使用 7 字节,如 ascii
中文使用使用 9 字节也许是 utf8
但在韩语中,出现了两种不同的结果,
有人知道吗