I'm trying to determine if a string is latin based or Japanese.
I've tried something like the following but it returns YES for Japanese strings as well:
NSCharacterSet *alphaSet = [NSCharacterSet alphanumericCharacterSet];
BOOL isAlpha = [[myStr stringByTrimmingCharactersInSet:alphaSet] isEqualToString:@""];
A string might be a word like "café" or something like "カフェ" or "喫茶店".
Use the canBeConvertedToEncoding: method. For example:
BOOL isLatin = [myString canBeConvertedToEncoding:NSISOLatin1StringEncoding];
Available encodings are here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With