Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display emoji char in HTML

Tags:

I saved the face "savouring delicious food emoji" to database, and read it in php json_encode which show "uD83D\uDE0B"ใ€‚ but usually we use one <img /> label to replace it . however,usually I just find this format '\uE056' not "uD83D\uDE0B",to replace with pic E056.png .

I don't know how to get the pic accroding to 'uD83D\uDE0B'.someone know ?

What the relation between 'uD83D\uDE0B' and '\uE056'๏ผŒ they both represent emoji "savouring delicious food"?

like image 303
jason_luo Avatar asked May 14 '12 08:05

jason_luo


People also ask

How do I show emojis in HTML?

After declaration of charset, emojis can be added in HTML by using <p> and <span> tags. <p> tag is used to insert the emoji in a new line whereas <span> tag inserts the emoji in the same line.

What is the code for emojis in HTML?

Emoji Characters Emojis are also characters from the UTF-8 alphabet: ๐Ÿ˜„ is 128516. ๐Ÿ˜ is 128525. ๐Ÿ’— is 128151.

How do I put emojis in my code?

Simply install the extension from the VS Code Marketplace, Ctrl+Shift+P to open your command palette and choose Select Emoji. Search your emoji and click the emoji you want to use then Ctrl+V to paste it where you want.


2 Answers

The Unicode character U+1F60B FACE SAVOURING DELICIOUS FOOD is a so-called Plane 1 character, which means that its UTF-16 encoded form consists of two 16-bit code units, namely 0xD83D 0xDE0B. Generally, Plane 1 characters cause considerable problems because many programs are not prepared to deal with them, and few fonts contain them.

According to http://www.fileformat.info/info/unicode/char/1f60b/fontsupport.htm this particular character only exists in DejaVu fonts and in Symbola, but the versions of DejaVu Iโ€™m using donโ€™t contain it.

Instead of dealing with the problems of encodings (which are not that difficult, but require extra information), you can use the character reference &#x1f608; in HTML. But this does not solve the font problem. I donโ€™t know about iPhone fonts, but in general in web browsing, the odds of a computer having any font capable of rendering the character are probably less than 1%. So you may need to use downloadable fonts. Using an image is obviously much simpler and mostly more reliable.

U+E056 is a Private Use codepoint, which means that anybody can make an agreement about its meaning with his brother or with himself, without asking anyone elseโ€™s mind. A font designer may assign any glyph to it.

like image 91
Jukka K. Korpela Avatar answered Sep 20 '22 05:09

Jukka K. Korpela


IMPORTANT: As of this posting, the only browser that doesn't automatically support emojis is chrome.

FOR CHROME: Depending on what server side language you are using, you should be able to find a library that converts emojis for you. I recently needed to solve this issue with php and used this library:

https://github.com/iamcal/php-emoji

The creator essentially created a sprite and adjusts the css according to the unicode of the emoji. It isnt pretty, but luckily he/she did all the grunt work for you. If you're using a different language you should be able to find something similar.

like image 28
Gideon Rosenthal Avatar answered Sep 22 '22 05:09

Gideon Rosenthal