iOS

iOS__ 怎么判断字符串是汉字还是字母

2017-01-11  本文已影响222人  CoderJohnhao
if(self.textLabel){
        for (int i=0; i<self.textLabel.length; i++) {
            NSRange range=NSMakeRange(i,1);
            NSString *subString=[self.textLabel substringWithRange:range];
            const char *cString=[subString UTF8String];
            if (strlen(cString) == 3)
            {
                NSLog(@"是汉字");
            }else if(strlen(cString) == 1)
            {
                NSLog(@"是字母");
            }
        }
    }
上一篇 下一篇

猜你喜欢

热点阅读