Emoji in strings.xml file?

爷,独闯天下 提交于 2019-12-23 12:27:42

问题


My string.xml is utf-8.

<string name="id">Hi \u0026</string>

^This worked. and showed as: Hi &.

But this does not work with this emoji 👈:

<string name="id">Hi \u1F448</string>

https://www.compart.com/en/unicode/U+1F448

How can I make it work with 👈?


回答1:


Use HTML Entity (decimal) i.e. &#128072; to add 👈 in strings.xml and use it in your app.

So your string will be:

<string name="emoji">Hi &#128072;</string>

Output:

For more information please check here




回答2:


Using HTML encoding is not working for me, at least when using the HTML code as &#2764 for the red heart emoji in the translation editor. I copied the unicode number from https://emojipedia.org/emoji/%E2%9D%A4/

However, just pasting it as the emoji character from clipboard ❤️ direct into the translations editor worked just fine, and perhaps I needn't have worried at all.



来源:https://stackoverflow.com/questions/52068120/emoji-in-strings-xml-file

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