Javascript parse error on '\u2028' unicode character

后端 未结 4 1172
南笙
南笙 2020-11-30 21:12

Whenever I use the \\u2028 character literal in my javascript source with the content type set to \"text/html; charset=utf-8\" I get a javascript parse errors.

Examp

4条回答
  •  鱼传尺愫
    2020-11-30 21:58

    Well, that makes sense, since you are telling the browser that the HTML and script are both using UTF-8, but then you specify a character that is not UTF-8 encoded. When you specify "charset=UTF-8", you are respoonsible for making sure the bytes transmitted to the browser are actually UTF-8. The web server and and browser will not do it for you in this situation.

提交回复
热议问题