首页 > 其他 > 详细

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

时间:2015-04-28 17:41:09      阅读:168      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!