How can I convert a string into a unicode character?

后端 未结 5 1980
庸人自扰
庸人自扰 2021-01-31 15:17

In Javascript \'\\uXXXX\' returns in a unicode character. But how can I get a unicode character when the XXXX part is a variable?

For example:<

5条回答
  •  执笔经年
    2021-01-31 15:40

    String.fromCharCode("0x" + input)

    or

    String.fromCharCode(parseInt(input, 16)) as they are 16bit numbers (UTF-16)

提交回复
热议问题