Skip to content

Instantly share code, notes, and snippets.

@badeen
Created July 18, 2012 22:29
Show Gist options
  • Save badeen/3139369 to your computer and use it in GitHub Desktop.
Save badeen/3139369 to your computer and use it in GitHub Desktop.
Handling emoji correctly
// 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