How to display a colored emoji

百般思念 提交于 2020-01-23 11:40:13

问题


My code:

let myemoji = "\u{2049}"
let another = "\u{2757}"

Playground result:

The Unicode U+2049 does not produce a red colored emoji like this ⁉️. Is there anything specific to be added for this color?


回答1:


Some characters can be displayed "as text" or "as emoji", and a "Unicode VARIATION SELECTOR" can be used to control the presentation. Example:

print("text presentation:  \u{2049}  \u{25B6}")
print("emoji presentation: \u{2049}\u{FE0F} \u{25B6}\u{FE0F}")

Result:

For more information, see 1.4.3 Emoji and Text Presentation Sequences:

ED-8. text presentation selector — The character U+FE0E VARIATION SELECTOR-15, used to request a text presentation for an emoji character. (Also known as text variation selector in prior versions of this specification.)

ED-9. emoji presentation selector — The character U+FE0F VARIATION SELECTOR-16, used to request an emoji presentation for an emoji character. (Also known as emoji variation selector in prior versions of this specification.)

or Variation Selector-16:

An invisible codepoint which specifies that the preceding character should be displayed with emoji presentation. Only required if the preceding character defaults to text presentation.



来源:https://stackoverflow.com/questions/48534667/how-to-display-a-colored-emoji

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!