Converting unicode character to string format

后端 未结 5 2209
失恋的感觉
失恋的感觉 2020-11-30 07:44

Does anyone know how to convert a unicode to a string in javascript. For instance:

\\u2211 -> ∑ \\u0032 -> 2 \\u222B -> ∫

5条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-30 07:52

    To convert an given Unicode-Char like  to String-Representation, you can also use this one-liner:

    var unicodeToStr = ''.codePointAt(0).toString(16)
    

    The above example gives you 'F21D'. Used with fontAwesome, you get street-view Icon: '\F21D'

提交回复
热议问题