[英]Convert U+ unicode to NSString
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
. 我要参考此表( https://unicodey.com/emoji-data/table.htm ),并希望转换
U+1F1E6 U+1F1FA
代码以在NSString
显示它。 How can I do that? 我怎样才能做到这一点? I don't have the \\u format unicode otherwise it would work automatically.
我没有\\ u格式的Unicode,否则它将自动运行。
NSString
is encoded as UTF-16, so U+1F1E6 U+1F1FA
can be expressed in code using \\u\u003c/code> notation:
"\?\?\?\?"
.
NSString
编码为UTF-16,因此U+1F1E6 U+1F1FA
可以使用\\u\u003c/code>表示法在代码中表示:
"\?\?\?\?"
。 Or, if you use
\\U
notation instead, you can use the actual codepoints as-is: "\\U0001F1E6\\U0001F1FA"
. 或者,如果改用
\\U
表示法,则可以按原样使用实际的代码点: "\\U0001F1E6\\U0001F1FA"
。
In Swift, it would be expressed as
"\\u{1F1E6}\\u{1F1FA}"
instead. 在Swift中,它将表示为
"\\u{1F1E6}\\u{1F1FA}"
。
In either case, you can alternatively just put the Unicode characters directly in the string literal and not escape them at all:
"🇦🇺"
. 在任何一种情况下,您都可以将Unicode字符直接放在字符串文字中,而根本不转义它们:
"🇦🇺"
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.