NSString with Emojis
emoji, macos, nsstring, objective-c, unicode
Solution
Not my best work, but it appears to work:
for (NSString *string in array)
{
@autoreleasepool {
NSScanner *scanner = [NSScanner scannerWithString:string];
unsigned int val = 0;
(void) [scanner scanHexInt:&val];
NSString *newString = [[NSString alloc] initWithBytes:&val length:sizeof(val) encoding:NSUTF32LittleEndianStringEncoding];
NSLog(@"%@", newString);
[newString release]; // don't use if you're using ARC
}
}
Using an array of four of your sample value, I get four pairs of bare feet.
Problem
I have a NSArray containing NSStrings with emoji codes in the following format: 0x1F463 How can I now convert them into a NSString with the correct format? With this method I am able to generate an "Emoji"-NSString: ``` NSString *emoji = [NSString stringWithFormat:@"\U0001F463"]; ``` But this is only possible with constant NSStrings. How can I convert the whole NSArray?