Converting emoji from hex code to unicode

2020-07-27 12:00发布

问题:

I want to use emojis in my iOS and Android app. I checked the list of emojis here and it lists out the hex code for the emojis. When I try to use the hex code such as U+1F600 directly, I don't see the emoji within the app. I found one other way of representing emoji which looks like \uD83D\uDE00. When using this notation, the emoji is seen within the app without any extra code. I think this is a Unicode string for the emoji. I think this is more of a general question that specific to emojis. How can I convert an emoji hex code to the Unicode string as shown above. I didn't find any list where the Unicode for the emojis is listed.

回答1:

It seems that your question is really one of "how do I display a character, knowing its code point?"

This question turns out to be rather language-dependent! Modern languages have little trouble with this. In Swift, we do this:

$ swift
Welcome to Apple Swift version 3.0.2 (swiftlang-800.0.63 clang-800.0.42.1). Type :help for assistance.
  1> "\u{1f600}"
$R0: String = "              
                            
标签: unicode emoji