私はtwemojiライブラリを使用して、Webページに顔文字画像を表示しています。絵文字を表示するには ud83d ude1bをどのように変換できますか?
私のデータベースにメッセージ内に"\ud83d\ude1b \ud83d\ude1b,hi"
のようなコードが格納されています。これで、自分のウェブページに対応する絵文字を表示する必要があります。
私は絵文字に"\u1F603"
を変換するPHPスクリプトを使用しています: - 、
$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);
}
どのようにすることができます私は同様の方法でWebページに絵文字のアイコンを表示するためにPHPを使用して\ud83d\ude1b \ud83d\ude1b
を変換しますか?
'\ u1F603'は' \ XF0 \ x9Fの\ x98と同じである場合\ '\ ud83d \ ude1b \ ud83d \ ude1b'も' \ xF0 \ x9F \ x98 \ x83'である方法よりも、 – Justinas
@Justinas、申し訳ありません、私は私の質問を編集しました。 – Saswat
あなたの提供されたコード*は '\ u1F603'を' \ xF0 \ x9F \ x98 \ x83'に変換しません:http://sandbox.onlinephpfunctions.com/code/0de4bd662dbb0f0790ff36306707eedc23b868c6 – Justinas