12

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 ?

Vikasdeep Singh
  • 20,983
  • 15
  • 78
  • 104
JJ Liu
  • 1,351
  • 8
  • 20
  • 36
  • this link can help you https://stackoverflow.com/questions/35792856/emoji-symbol-in-string-xml-crashes-app – GianhTran Aug 29 '18 at 01:09
  • @GianhTran I read that link before but I am still not sure one work but the other does not. Can Android only render 'basic' emoji but not fancier ones? I don't think so... – JJ Liu Aug 29 '18 at 01:16

2 Answers2

26

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:

enter image description here

For more information please check here

Vikasdeep Singh
  • 20,983
  • 15
  • 78
  • 104
3

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.

Dhiraj Gupta
  • 9,704
  • 8
  • 49
  • 54