how to render 32bit unicode characters in google v8 (and nodejs)

后端 未结 2 1870
栀梦
栀梦 2021-01-12 02:25

does anyone have an idea how to render unicode \'astral plane\' characters (whose CIDs are beyond 0xffff) in google v8, the javascript vm that drives both google chrome and

相关标签:
2条回答
  • 2021-01-12 03:07

    This recent presentation covers all sorts of issues with Unicode in popular languages, and isn't kind to Javascript: The Good, the Bad, & the (mostly) Ugly

    He covers the issue with two-byte representation of Unicode in Javascript:

    The UTF‐16 née UCS‐2 Curse

    Like several other languages, Javascript suffers from The UTF‐16 Curse. Except that Javascript has an even worse form of it, The UCS‐2 Curse. Things like charCodeAt and fromCharCode only ever deal with 16‐bit quantities, not with real, 21‐bit Unicode code points. Therefore, if you want to print out something like

    0 讨论(0)
  • 2021-01-12 03:09

    I think it's a console.log issue. Since console.log is only for debugging do you have the same issues when you output from node via http to a browser?

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