1

I am working on emojis with iPhone. I want to convert something like "\u1F604" (NSString) to "\U0001F604"(NSString) format.

How can i do that?

Thanks,
Jim.

Jim
  • 4,639
  • 5
  • 27
  • 31
  • Replace small u by U000 .If retVal=@"\u1F604" then [retVal stringByReplacingOccurrencesOfString:@"u" withString:@"U000" ]; I hope this is what u want. – Divya Dec 18 '12 at 11:15
  • @Divya: this may be obvious case if i want to replace but i am looking for generic case where if i have "\u2723" then it should give me "\U00002723". – Jim Dec 18 '12 at 11:20
  • See my question here may be it help you - http://stackoverflow.com/questions/12140770/does-ios-support-all-unicode-emojies – TheTiger Dec 18 '12 at 11:34
  • Where did you get `"\u1F604"`? That's invalid for `U+1F604`, it means `"\u1F60"` and then literally the digit `"4"`. There must be exactly 4 hex digits, otherwise it's ambiguous. I don't believe a machine generated this? – Esailija Dec 18 '12 at 11:41
  • I have posted one smiley character to server and server is returning me \u1F604. This is as per new unicode 6.0 specification.Please have a look at http://punchdrunker.github.com/iOSEmoji/table_html/index.html – Jim Dec 18 '12 at 11:47
  • 2
    @Jim no it isn't, you are talking about code point notation `U+1F604`, *not* short unicode escape sequence `\uxxxx`. The \u-scheme would encode `U+1F604` as `\ud83d\ude04`. See http://jsfiddle.net/2A2tT/. If a server is returning `\u1F604`, that's broken server. Because there is no way to tell if it means the emoji, or accented small omega and the digit 4 – Esailija Dec 18 '12 at 11:49

1 Answers1

0

Please try the below code.

NSString* resultTemp = @"\u1F604";
NSData* data = [resultTemp dataUsingEncoding:NSUTF16StringEncoding];
NSString* result = [[NSString alloc] initWithData:data encoding:NSUTF16StringEncoding];
self.detailDescriptionLabel.text = result;
Paramasivan Samuttiram
  • 3,728
  • 1
  • 24
  • 28
  • Not getting correct emoji icon using above solution. It is coming as "ὠ4" rather than smiley icon.✨ – Jim Dec 18 '12 at 11:29