iOS 判定string是不是中文字符

Posted 懒懒初阳

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了iOS 判定string是不是中文字符相关的知识,希望对你有一定的参考价值。

 1 +(BOOL)IsChinese:(NSString *)str
 2 {
 3     for(int i=0; i< [str length];i++)
 4     {
 5         int a = [str characterAtIndex:i];
 6         if( a > 0x4e00 && a < 0x9fff)
 7         {
 8             return YES;
 9         }
10         
11     }
12     return NO;
13 }

 

以上是关于iOS 判定string是不是中文字符的主要内容,如果未能解决你的问题,请参考以下文章