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 stringByTrimmingChara开发者_高级运维ctersInSet: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.
精彩评论