js中escape()、encodeURI()、encodeURIComponent()的区别

来源:互联网 发布:slackware linux 编辑:程序博客网 时间:2024/06/05 01:34

1.escape()不能直接用于URL编码,它的真正作用是返回一个字符的Unicode编码值。

2.encodeURI()除了常见的符号以外,对网址中有特殊含义的符号“; / ? : @ & = + $ , #”,不进行编码。编码后,它输出符号的utf-8形式,并且在每个字节前加上%。

3.encodeURIComponent() 像”; / ? : @ & = + $ , #”,这些在encodeURI()中不被编码的符号,在encodeURIComponent()中统统会被编码。

4.encodeURI()和encodeURIComponent()都不会对 ASCII 字母和数字进行编码,也不会对这些 ASCII 标点符号进行编码: - _ . ! ~ * ’ ( ) 。

阅读全文
0 0