Otá*_*eto 4 html php unicode function emoji
我正在尝试使用 php 将表情符号转换为 unicode ,更多信息:https://unicode.org/emoji/charts/full-emoji-list.html
如何U+1F603用php将其转换成这样?
function convert_emoji($var){
}
Run Code Online (Sandbox Code Playgroud)
我找到了一个简单的方法来解决,所以我会回答我自己的问题,但如果有人想改进这个功能,那就很酷了。
<?php
function emoji_to_unicode($emoji) {
$emoji = mb_convert_encoding($emoji, 'UTF-32', 'UTF-8');
$unicode = strtoupper(preg_replace("/^[0]+/","U+",bin2hex($emoji)));
return $unicode;
}
$var = "";
echo emoji_to_unicode($var);
?>
Run Code Online (Sandbox Code Playgroud)