开发者

How to compare A to Á on the iPhone

I need to compare 2 strings, looking at the first letter only.

Is the开发者_运维问答re a method to compare A to Á, and recognize it as A, without the ´?


NSString has a diacritic-insensitive comparison mode which will do what you're after.

// should return NSOrderedSame, i.e. identical
[@"Apple" compare:@"Ápple" 
          options:NSDiacriticInsensitiveSearch]

If you want it to be case-insensitive as well:

// ditto
[@"APPLE" compare:@"Ápple" 
          options:NSDiacriticInsensitiveSearch | NSCaseInsensitiveSearch] 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜