How to compare A and Á on iPhone

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

Is there a way to compare A with Á and recognize it as A without ´?

+3
source share
1 answer

NSString has a diacritically sensitive comparison mode that will do what you need.

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

If you want it to be case insensitive:

// ditto
[@"APPLE" compare:@"Ápple" 
          options:NSDiacriticInsensitiveSearch | NSCaseInsensitiveSearch] 
+6
source

Source: https://habr.com/ru/post/1779780/


All Articles