Javascript的解码/编码api

 

1、fromCharCode() 接受一个指定的 Unicode 值,然后返回一个字符串。

语法:String.fromCharCode(numX,numX,...,numX)

详细了解:http://www.w3school.com.cn/jsref/jsref_fromCharCode.asp

 

2、charCodeAt() 返回指定位置的字符的 Unicode 编码。返回值是 0 - 65535 之间的整数。

语法:stringObject.charCodeAt(index)

详细了解:http://www.w3school.com.cn/jsref/jsref_charCodeAt.asp

 

3、encodeURI() 把字符串作为 URI 进行编码。

语法:encodeURI(URIstring)

该方法不会对 ASCII 字母和数字进行编码,也不会对这些 ASCII 标点符号进行编码: - _ . ! ~ * ' ( ) 。

如果 URI 组件中含有分隔符,比如 ? 和 #,则应当使用 encodeURIComponent() 方法分别对各组件进行编码。

详细了解:http://www.w3school.com.cn/jsref/jsref_encodeuri.asp

 

4、decodeURI()  对 encodeURI() 函数编码过的 URI 进行解码。

语法:decodeURI(URIstring)

详细了解:http://www.w3school.com.cn/jsref/jsref_decodeURI.asp

 

5、 encodeURIComponent() 把字符串作为 URI 组件进行编码。

语法:encodeURIComponent(URIstring)

详细了解:http://www.w3school.com.cn/jsref/jsref_encodeURIComponent.asp

 

6、decodeURIComponent()  对 encodeURIComponent() 函数编码的 URI 进行解码。

语法:decodeURIComponent(URIstring)

详细了解:http://www.w3school.com.cn/jsref/jsref_decodeURIComponent.asp

 

 

此文为纯整理。会持续更新...

 

 

posted @ 2018-09-26 15:41  幸福n-1次方  阅读(325)  评论(0编辑  收藏  举报