-(NSUInteger)textLength: (NSString *) text{
NSUInteger asciiLength = 0;
for (NSUInteger i = 0; i < text.length; i++) {
unichar uc = [text characterAtIndex: i];
asciiLength += isascii(uc) ? 1 : 2;
}
NSUInteger unicodeLength = asciiLength;
return unicodeLength;
}
iOS判断一段字符串长度(汉字2字节)
最新推荐文章于 2022-06-09 16:13:09 发布