#pragma mark - 判断字符串 是不是 全是中文
- (BOOL)xnIsChinese
{
NSString *match = @"(^[\u4e00-\u9fa5]+$)";
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF matches %@", match];
return [predicate evaluateWithObject:self];
}
#pragma mark - 判断字符串 是不是 包含中文
- (BOOL)xnIsIncludeChinese
{
for(int i=0; i< [self length];i++)
{
int a =[self characterAtIndex:i];
if( a >0x4e00&& a <0x9fff){
return YES;
}
}
return NO;
}
学自: 梦亦趣 (简书)