Javascript URL 转义字符

来源:互联网 发布:centos ruby 版本升级 编辑:程序博客网 时间:2024/05/29 03:50
 

Javascript URL 转义字符

 

1、
  encodeURIComponent(”[string]“)
  decodeURIComponent(”[encodedString]“)

2、
  encodeURI(”[string]“)
  decodeURI(”[encodedString]“)

3、
  escape(”[string]“)
  unescape(”[encodedString]“)

Note:
  a、The both of 1 and 2 encodes/decodes in “utf-8″
  b、The both of 1 and 2 can not encode _-~*.’
  c、The difference of 1 and 2 is 2 can not encoding /?&+=$@,;
  d、The 3 encodes/decodes in “ISO Latin”

附注:URL编码规则

1、对每个字节进行编码;
2、空格转为”+”号;
3、安全字符不编码。安全字符:大小写英文字母(a-z以及A-Z) 阿拉伯数字(0-9) \’ ( ) * - . _ !
4、其他字节以十六进制显示并加”%”前缀,例如用%25代表%号。

 

原创粉丝点击