Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSString - Unicode to ASCII equivalent

Tags:

I need to convert NSString in unicode to NSString in ASCII changing all local characters: Ą to A, Ś to S, Ó to O, ü to u, And so on...

What is the simplest way to do it?

like image 275
Jacek Avatar asked Apr 07 '10 08:04

Jacek


1 Answers

-[NSString dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES].

All of the examples you gave are handled as you want. Looks like characters with no obvious analog, such as ☃, go to '?'.

like image 133
Ken Avatar answered Nov 09 '22 23:11

Ken