In some languages there are letters like À
, I saw that for table view sections the native iOS put À
under the same section as A
.
I wan
You can convert it first into regular alphabets and then compare.
NSString *originalStr = @"À béautiful day";
NSData *d = [originalStr dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *converted = [[NSString alloc] initWithData:d encoding:NSASCIIStringEncoding];
Don't convert or transform as per the other answers. First, try -[NSString localizedStandardCompare:]
. If that doesn't do what you want, pass NSDiacriticInsensitiveSearch
among the options to one of the NSString
comparison methods (such as -compare:options:range:locale:
). You may want to use additional options, too, such as NSCaseInsensitiveSearch
.
Here's a great article about CFStringTransform
on NSHipser http://nshipster.com/cfstringtransform/
Next, apply the kCFStringTransformStripCombiningMarks transform to remove any diacritics or accents.