前端的字符编码

 

HTML

HTML 中的预留字符必须被替换为字符实体。http://www.w3school.com.cn/html/html_entities.asp

<:&lt;或&#60;
理:&#29702;或&#x7406;
财:&#36130;或&#x8D22;
 
 

JS

<: 对应的十进制是60
'\<' === '<' // true
'\74' === '<' // true 8进制
'\x3C' === '<' // true 16进制
'\u003C' === '<' // true unicode
'\u{3C}' === '<' // true unicode
 
unicode形式
<:\u003c
理:\u7406
财:\u8d22
 

URL

推荐所有的url的参数都做encodeURIComponent,获取url参数时做decodeURIComponent

posted @ 2020-03-27 10:52  chua1989  阅读(359)  评论(0编辑  收藏  举报