-(
NSUInteger
) unicodeLengthOfString: (
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 / 2 ;
if (asciiLength % 2 ) {
unicodeLength++;
}
return unicodeLength;
}
NSUInteger asciiLength = 0 ;
for ( NSUInteger i = 0 ; i < text. length ; i++) {
unichar uc = [text characterAtIndex : i];
asciiLength += isascii (uc) ? 1 : 2 ;
}
NSUInteger unicodeLength = asciiLength / 2 ;
if (asciiLength % 2 ) {
unicodeLength++;
}
return unicodeLength;
}