判断字符串是否有汉字

    NSString *bundleName = @"abcd宾";
    for (int i = 0; i < bundleName.length; i++) {
        NSRange range = NSMakeRange(i,1);
        NSString *subString = [bundleName substringWithRange:range];
        const char *cString = [subString UTF8String];
        if (strlen(cString) == 3) {
            NSLog(@"汉字");
        } else {
            NSLog(@"非汉字");
        }
    }


你可能感兴趣的:(判断字符串是否有汉字)