码迷,mamicode.com
首页 > 其他好文 > 详细

计算字符数字标点方法**

时间:2015-04-28 17:43:38      阅读:120      评论:0      收藏:0      [点我收藏+]

标签:

-(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;
    
}

计算字符数字标点方法**

标签:

原文地址:http://www.cnblogs.com/wq-gril/p/4463465.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!