I am referring to this table (https://unicodey.com/emoji-data/table.htm) and want to convert a U+1F1E6 U+1F1FA
code to display it in NSString
. How can I do that? I don't have the \u format unicode otherwise it would work automatically.
NSString
is encoded as UTF-16, so U+1F1E6 U+1F1FA
can be expressed in code using \u
notation: "\uD83C\uDDE6\uD83C\uDDFA"
. Or, if you use \U
notation instead, you can use the actual codepoints as-is: "\U0001F1E6\U0001F1FA"
.
In Swift, it would be expressed as "\u{1F1E6}\u{1F1FA}"
instead.
In either case, you can alternatively just put the Unicode characters directly in the string literal and not escape them at all: "🇦🇺"
.