Array of html entities “” how to print? as unicode (not working)?

前端 未结 1 1368
梦谈多话
梦谈多话 2021-01-27 06:28

I have an array of HTML entities (custom font) that looks like this:

const arr = [\'\'];

Now when I print it out like this:

1条回答
  •  萌比男神i
    2021-01-27 07:12

    String.fromCodePoint(parseInt(arr[0].replace(/&#x|;/g,''),16))
    //
    

    Try this first we replace '&#x' and ';' with '', then with parseInt() we convert it from hexadecimal to decimal, then with String.fromCodePoint() we convert the decimal code point into a Javascript string.

    0 讨论(0)
提交回复
热议问题