Andrew Varvel Andrew Varvel - 5 months ago 74
Swift Question

Convert Unicode (e.g. 1f564) to Emoji in Swift

How do you convert unicode emoji stored as a string (e.g.

) to an emoji that could be placed on a UILabel?

let myString = "1f564"

I've seen the use of the escape character but I can't insert variables to replace the characters.

let flag = "\u{1f1e9}\u{1f1ea}"



This works. I don't know if there is anything more direct:

let myStr = "1f564"
let str = String(UnicodeScalar(Int(myStr, radix: 16)!))