如何比较objective-c中的unicode字符



我试图比较unicode字符在我的应用程序,,

使用

if([str charcterAtIndex:i] == 'w')
  nslog......

它工作正常

但是当字母是阿拉伯字母"时,它就不存在了!!

有什么特别的方法吗?

感谢

您应该将它们设置为UTF-8

const char* utfStr1 = [yourString UTF8String];
const char* utfStr2 = [yourString2 UTF8String];

,然后比较

if([utfStr1 isEqualToString:utfStr2]) NSLog(@"true");

最新更新