- (BOOL)ItIsLegalToHaveANickname
{
BOOL isLegal = YES;
NSString *testString = @"123中文小e大E";
int alength = [testString length];
for (int i = 0; i < alength; i++) {
int commitChar = [testString characterAtIndex:i];
NSString *temp = [testString substringWithRange:NSMakeRange(i, 1)];
const char *u8Temp = [temp UTF8String];
StrLength(u8Temp); // 获取ASCII值
if (commitChar > 0x4e00 && commitChar < 0x9fff) {
NSLog(@"字符串中含中文 %d", StrLength(u8Temp));
}else if ((commitChar>64)&&(commitChar<91)) {
NSLog(@"字符串中含有大写英文字母");
}else if ((commitChar>96)&&(commitChar<123)) {
NSLog(@"字符串中含有小写英文字母");
}else if ((commitChar>47)&&(commitChar<58)) {
NSLog(@"字符串中含有数字");
}else {
NSLog(@"字符串中含有非法字符");
isLegal = NO;
}
}
return isLegal;
}