Turn from: http://www.jb51.net/article/36480.htm
encodeURI and decodeURI are used in pairs, because the browser's address bar has Chinese characters, you can have unexpected errors, so you can encodeuri to translate non-English characters into English code, decodeURI can be used to restore the characters back
I. Basic CONCEPTS
encodeURI and decodeURI are used in pairs, because the browser's address bar has Chinese characters, you can have unexpected errors, so you can encodeuri to translate non-English characters into English code, decodeURI can be used to restore the characters back. The encodeURI method does not encode the following characters: ":", "/", ";" and "?", and the encodeURIComponent method can encode these characters.
The decodeURI () method is equivalent to Java.net.URLDecoder.decode (uristring, "UTF-8");
The encodeURI () method is equivalent to Java.net.URLEncoder.encode (uristring, "UTF-8");
Second, examples
<script type= "Text/javascript" >
var uristr = "Http://www.baidu.com?name= John &num=001";
var Uriec = encodeURI (URISTR);
document.write ("encoded" + Uriec);
var uridc = decodeURI (Uriec);
document.write ("decoded" + URIDC);
Http://www.baidu.com?name=%E5%BC%A0%E4%B8%89&num=001%20zs after the encoding
Decoding of http://www.baidu.com?name= John &num=001 Zs