How to use five digit long Unicode characters in JavaScript

前端 未结 5 2083

In JavaScript I can do this:

foo = \"\\u2669\" // 1/4 note

But I can\'t do this

foo = \"\\u1D15D\" // full note  -five hex digi         


        
5条回答
  •  执笔经年
    2021-02-19 10:24

    Nowadays, you can simply use String.fromCodePoint(), as documented in MDN. For instance:

    > String.fromCodePoint(0x1f0a1)
    "

提交回复
热议问题