我正在尝试在聊天应用程序中渲染表情符号,但无法让由多个部分构建的表情符号正常工作。
例如:
作品26f9的代码点Person with Ball
const emoji = String.fromCodePoint('0x26f9');
Run Code Online (Sandbox Code Playgroud)
但26f9-fe0f-200d-2640-fe0f对于Woman bouncing ball不起作用
const emoji = String.fromCodePoint('0x26f9-fe0f-200d-2640-fe0f');
Run Code Online (Sandbox Code Playgroud)
弄清楚了:
const codePointString = '26f9-fe0f-200d-2640-fe0f';
const emoji = codePointString.split('-').map((codePoint) => (
String.fromCodePoint(`0x${codePoint}`)
)).join('');
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
285 次 |
| 最近记录: |