Skip to content

Instantly share code, notes, and snippets.

@mindbrix
Last active August 29, 2015 14:03
Show Gist options
  • Save mindbrix/710707d3dec311196e5e to your computer and use it in GitHub Desktop.
Save mindbrix/710707d3dec311196e5e to your computer and use it in GitHub Desktop.
Unicode char to NSString
NSString *hexString = @"1F0A7";
unsigned int character;
NSScanner* scanner = [NSScanner scannerWithString:hexString ];
[ scanner scanHexInt:&character ];
UTF32Char inputChar = NSSwapHostIntToLittle(character); // swap to little-endian if necessary
NSString *str = [[NSString alloc] initWithBytes:&inputChar length:4 encoding:NSUTF32LittleEndianStringEncoding];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment