Converting text to Unicode in javascript

前端 未结 3 912
自闭症患者
自闭症患者 2020-12-17 06:51

I have the following:

function showUnicode()
{
  var text = prompt( \'Enter the wanted text\', \'Unicode\' ),
      unicode = 0,
      ntext,
      temp,
            


        
相关标签:
3条回答
  • 2020-12-17 07:24

    JavaScript uses UCS-2 internally.

    This means that supplementary Unicode symbols are exposed as two separate code units (the surrogate halves). For example, '

    0 讨论(0)
  • 2020-12-17 07:28

    NaN = Not a Number

    You need to initialize "unicode" as a numeric type:

    var unicode = 0
    
    0 讨论(0)
  • 2020-12-17 07:44

    You should initialize the unicode variable to something, or you're adding the char codes to undefined.

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