Created
July 18, 2012 22:29
-
-
Save badeen/3139369 to your computer and use it in GitHub Desktop.
Handling emoji correctly
This file contains hidden or 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
// I take a string from a text field (which includes emoji) and apply this to it so that my JSON parser doesn't freak out when it comes back to me. | |
NSData *stringData = [message dataUsingEncoding:NSNonLossyASCIIStringEncoding]; | |
NSString *safeString = [[NSString alloc] initWithData:stringData encoding:NSUTF8StringEncoding]; | |
// I try to draw the string I get back from the server (I sent it safeString from above). | |
// When I draw it I end up getting text like this drawn: | |
// Test emoji \ud83d\ude03 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment