jQuery.parseJSON \u0092 character is not parsed

前端 未结 2 1302
走了就别回头了
走了就别回头了 2021-01-20 05:13

I have a text encoded from php with an ajax function with de php utf8_encode.If I print it in the console directly the text is displayed as follows :

\"proj         


        
2条回答
  •  不思量自难忘°
    2021-01-20 05:44

    It is parsed by jQuery. A simple test can show you:

    > $.parseJSON('"\\u0092"').length 
    1
    > $.parseJSON('"\\u0092"').charCodeAt(0)
    146
    > $.parseJSON('"\\u0092"').charCodeAt(0).toString(16)
    "92"
    

    It only won't get displayed, see @TJCrowders answer for that.

提交回复
热议问题