我正在使用twemoji库在网页中显示表情符号图像。
我在数据库中的消息中存储了像"\ud83d\ude1b \ud83d\ude1b,hi"这样的代码,现在我需要在我的网页上显示相应的表情符号。
我正在使用PHP script将"\u1F603"转换为emoji:-,
$text = "This is fun \u1f602! \u1f1e8 ";
$html = preg_replace("/\\\\u([0-9A-F]{2,5})/i", "&#x$1;", $text);
echo $html;然后我使用twemoji来解析正文,并将其替换为表情图标:
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);
}如何使用PHP以类似的方式转换\ud83d\ude1b \ud83d\ude1b,以便在网页中显示表情图标?
https://stackoverflow.com/questions/39227482
复制相似问题