How can I convert a string into a unicode character?

后端 未结 5 1989
庸人自扰
庸人自扰 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:35

    var hex = '2122';
    var char = unescape('%u' + hex);
    
    console.log(char);
    

    will returns " ™ "

提交回复
热议问题