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

相关文章:

  • 2022-12-23
  • 2021-12-14
  • 2022-01-30
  • 2021-09-23
  • 2022-12-23
  • 2021-12-07
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-03-02
  • 2022-01-13
  • 2021-12-14
相关资源
相似解决方案