Created
March 9, 2014 22:33
-
-
Save kharmabum/9455960 to your computer and use it in GitHub Desktop.
NSString length hack - http://www.objc.io/issue-9/unicode.html
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
NSUInteger realLength = [s lengthOfBytesUsingEncoding:NSUTF32StringEncoding] / 4; | |
NSLog(@"The real length of %@ is %lu", s, realLength); | |
// => The real length of 🌍 is 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment