Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emoji in strings.xml file?

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 👈?

like image 895
JJ Liu Avatar asked Aug 29 '18 01:08

JJ Liu


People also ask

Are Emojis valid in XML?

You can put emojis in an XML, and the squares are just the editor's way to render characters it can't recognize, like all other characters, you can specify the character by its UTF8 value instead. For example, 😃 has the char value of 128515, so you could use &#128515; to specify it.

Why do Emojis show up as boxes on Android?

When displaying an emoji, your device looks up the image it should show for the given code point. When it comes across a "code point" it doesn't understand, it shows a symbol to represent an unknown emoji. This symbol is the question mark or box, depending on the device.


1 Answers

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

like image 134
Vikasdeep Singh Avatar answered Nov 15 '22 21:11

Vikasdeep Singh