Created
July 28, 2016 09:14
-
-
Save agassiyzh/7b6ec49375dfcbf5a377893e39ca0150 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface NSString (TDF) | |
- (NSUInteger)tdf_chineseLength; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@implementation NSString(TDF) | |
- (NSUInteger)tdf_chineseLength { | |
NSInteger length = [self lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; | |
length -= (length - self.length) / 2; | |
length = (length +1) / 2; | |
return length; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment