I am using twemoji library to show emoticon image in Webpage.
I store codes like "\ud83d\ude1b \ud83d\ude1b,hi"
within messages in my database, and now I need to display the corresponding emoji on my web page.
I am using PHP script to convert "\u1F603"
to emoji:-,
$text = "This is fun \u1f602! \u1f1e8 ";
$html = preg_replace("/\\\\u([0-9A-F]{2,5})/i", "&#x$1;", $text);
echo $html;
Then I am using twemoji to parse the body and replace it with emoji icons:-
window.onload = function() {
// Set the size of the rendered Emojis
// This can be set to 16x16, 36x36, or 72x72
twemoji.size = '16x16';
// Parse the document body and
// insert <img> tags in place of Unicode Emojis
codePoint = twemoji.convert.toCodePoint($('.com-text').html());
twemoji.parse(document.body);
}
How can I convert \ud83d\ude1b \ud83d\ude1b
in similar way using PHP for displaying emoji icons in a web page?