Removing character accents in iOS / Objective-C
I was recently asked to capitalise some Greek strings in an app, only problem I had was the original string was lowercase and had accents. Apparently uppercase words in Greek (and possibly other languages) loose the accents…. :-/
Not being Greek or having a greek keyboard layout I needed a (simple) way to tackle this.
The following line of code successful strips out the character accents for Greek text and you can then in turn uppercase string these back into your app….
NSString *parsedString = [string stringByFoldingWithOptions:NSDiacriticInsensitiveSearch locale:[NSLocale currentLocale]];return [parsedString uppercaseString];
You could choose to create an extension or a protocol and have this sitting nicely within your codebase.