javascript使用的Unicode字符集,
javascript不仅以Unicode存储字符,还允许直接在程序中使用Unicode编号表示字符
*****
base64编码加密方式(非中文)
btoa() 字符串或者二进制值转为base64编码
btoa(string)
var test = "hello word !"
console.log(btoa(test)) //aGVsbG8gd29yZCAh
var test = 123
console.log(btoa(test)) //MTIz
atob() base64编码转为原来的编码
atob(string)
console.log(atob("aGVsbG8gd29yZCAh")) //hello word !
加密中文
encodeURLComponent()(加密)
decodeURLComponent()(解密)
var ch = "你好,世界 !"
console.log(encodeURIComponent(ch))
//%E4%BD%A0%E5%A5%BD%EF%BC%8C%E4%B8%96%E7%95%8C%20%EF%BC%81
console.log(decodeURIComponent(
"%E4%BD%A0%E5%A5%BD%EF%BC%8C%E4%B8%96%E7%95%8C%20%EF%BC%81"
))//你好,世界 !
页面更新:2024-04-02
本站资料均由网友自行发布提供,仅用于学习交流。如有版权问题,请与我联系,QQ:4156828
© CopyRight 2020-2024 All Rights Reserved. Powered By 71396.com 闽ICP备11008920号-4
闽公网安备35020302034903号