How to determine if an NSString is latin based?

前端 未结 1 1966
小蘑菇
小蘑菇 2021-01-17 15:28

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:

         


        
1条回答
  •  一整个雨季
    2021-01-17 16:05

    Use the canBeConvertedToEncoding: method. For example:

    BOOL isLatin = [myString canBeConvertedToEncoding:NSISOLatin1StringEncoding];
    

    Available encodings are here.

    0 讨论(0)
提交回复
热议问题