Reputation: 499
I'm trying to get the NSString
for the smiling emoji
whose utf-8 code is: 0xF0 0x9F 0x98 0x84
.
This works:
NSString *smile = [NSString stringWithUTF8String:"\xf0\x9f\x98\x84"];
but this doesn't:
NSString *smile = @"\uf0\u9f\u98\u84";
I get the error message: "Incomplete universal character name
". Can anyone help me with this? Thanks.
Upvotes: 0
Views: 1670
Reputation: 3328
You are missing 2 bytes here. The \u expects digits of 4.
For example : NSString *s = @"\u0234\u0355\u0666\u0621";
Upvotes: 1