简体   繁体   中英

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 . 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\u003c/code> notation: "\?\?\?\?" . 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: "🇦🇺" .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM