问题描述
我正在尝试在聊天应用中渲染表情符号,但无法使由多个部分构成的表情符号正常工作。
例如:
26f9
的代码点Person with Ball
有效
const emoji = String.fromCodePoint('0x26f9');
但是26f9-fe0f-200d-2640-fe0f
的{{1}}不起作用
Woman bouncing ball
解决方法
想通了:
const codePointString = '26f9-fe0f-200d-2640-fe0f';
const emoji = codePointString.split('-').map((codePoint) => (
String.fromCodePoint(`0x${codePoint}`)
)).join('');