ios 计算字符串长度<转>
- (int)textLength:(NSString *)text//计算字符串长度
{
float number = 0.0;
for (int index = 0; index < [text length]; index++)
{
NSString *character = [text substringWithRange:NSMakeRange(index, 1)];
if ([character lengthOfBytesUsingEncoding:NSUTF8StringEncoding] == 3)
{
number++;
}
else
{
number = number + 0.5;
}
}
return ceil(number);
}