From 875216064527deaf7876b4d6c48b479d65bef678 Mon Sep 17 00:00:00 2001 From: Fairy-Phy Date: Sun, 17 Sep 2023 01:34:45 +0900 Subject: [PATCH] =?UTF-8?q?=E4=B8=80=E9=83=A8=E7=B5=B5=E6=96=87=E5=AD=97?= =?UTF-8?q?=E3=81=AE=E3=83=90=E3=82=A4=E3=83=88=E5=A4=89=E6=8F=9B=E3=81=8C?= =?UTF-8?q?=E3=81=8A=E3=81=8B=E3=81=97=E3=81=8F=E3=81=AA=E3=82=8B=E5=95=8F?= =?UTF-8?q?=E9=A1=8C=E3=81=AE=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../frontend/src/scripts/emojiKitchen/emojiMixer.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/frontend/src/scripts/emojiKitchen/emojiMixer.ts b/packages/frontend/src/scripts/emojiKitchen/emojiMixer.ts index 654eb357f7..89ade45b24 100644 --- a/packages/frontend/src/scripts/emojiKitchen/emojiMixer.ts +++ b/packages/frontend/src/scripts/emojiKitchen/emojiMixer.ts @@ -26,17 +26,24 @@ const convertBase = (value, from_base, to_base) => { return new_value || '0'; }; +const emojiSplit = String.fromCodePoint(0x200d); const hexEncodeEmoji = (chr) => { - if (chr.length !== 1) { + if (chr.length === 3) return hexEncodeEmoji(chr.slice(0, 2)) + '-' + hexEncodeEmoji(chr.slice(2, chr.length)); + else if (chr.length === 2) { const hi = chr.charCodeAt(0); const lo = chr.charCodeAt(1); if (0xD800 <= hi && hi < 0xDC00 && 0xDC00 <= lo && lo < 0xE000) { return (0x10000 + (hi - 0xD800) * 0x400 + (lo - 0xDC00)).toString(16); } - return ("000" + hi.toString(16)).slice(-4) + '-' + ("000" + lo.toString(16)).slice(-4); + return hi.toString(16) + '-' + lo.toString(16); + } + else if (chr.length === 1) { + return chr.charCodeAt(0).toString(16); } else { - return ("000" + chr.charCodeAt(0).toString(16)).slice(-4); + const sp = chr.split(emojiSplit); + if (sp.length !== 2) return ''; + return hexEncodeEmoji(sp[0]) + '-200d-' + hexEncodeEmoji(sp[1]); } };