I'm trying to add support for emoji shortcodes in my iOS app to replace them with the actual emoji. For example, turning :+1: into . The data I'm using is at https://github.com/iamcal/emoji-data, and the issue I'm having is it's displayed as "unified": "1F44D"
, and i can't figure out how to turn that into an actual emoji.
Asked
Active
Viewed 252 times
-2

eskimo
- 304
- 1
- 3
- 15
-
1The link you have shown is a huge database of emojis and I cannot understand why you get only `"unified": "1F44D"`. Please show your **input data** (which may include `+1`), your **current code**. – OOPer Feb 17 '19 at 17:11
-
I think you really misunderstood. – eskimo Feb 17 '19 at 18:00
-
Please explain what I am misunderstanding. – OOPer Feb 17 '19 at 18:05
-
That one little line I included was just an example of what I need to translate to an emoji. Obviously I need to do it for all of them. – eskimo Feb 17 '19 at 18:09
-
Even if it is just an example, you wrote `it's displayed as "unified": "1F44D"` that means you have code which has displayed `"unified": "1F44D"`, no? I am just suggesting you should show the code. – OOPer Feb 17 '19 at 18:13
-
The point you're missing is: I need to translate "1F44D" into an emoji. – eskimo Feb 17 '19 at 18:14
-
What you are not understanding is, you wrote `it's displayed as "unified": "1F44D"`, so with showing your code, you have better chance to get the expected emoji sooner. – OOPer Feb 17 '19 at 18:22
-
@JoshCaswell You are correct. That looks like what I need. Thanks. – eskimo Feb 17 '19 at 18:40
1 Answers
1
The "1F44D" in this table is the unicode value in hex. Convert this to an integer, that to a UnicodeScalar, and that to a String or Character:
let unified = "1F44D"
if let value = Int(unified, radix: 16),
let scalar = UnicodeScalar(value) {
let string = String(scalar)
print(string)
}

Rob Napier
- 286,113
- 34
- 456
- 610
-
What about ones where they are like XXXXX-XXXXX-XXXXX. Do I need to split them and loop this then? – eskimo Feb 17 '19 at 18:03
-
1Ah; yeah, I see the sequences. Like 002A-FE0F-20E3. That's just three characters combined. ASTERISK, VARIATION SELECTOR-16 (i.e. "display previous character as emoji"), COMBINING ENCLOSING KEYCAP. Split on the `-` and put the three characters together in a String. Together that sequence combines to form *️⃣. – Rob Napier Feb 17 '19 at 19:22