encodeURI , encodeURIComponent , decodeURL , decodeURIComponent Transcoding and decoding summary

The encodeURI() function encodes a string as a URI. (only other characters (eg: ;/?:@&=+$,# punctuation used to separate URI components) are replaced with hexadecimal escape sequences)
The encodeURIComponent() function encodes a string as a URI component.
Tip: Note the difference between the encodeURIComponent() function and the encodeURI() function, which assumes that its argument is part of a URI (such as a protocol, hostname, path, or query string). So the encodeURIComponent() function will escape the punctuation that separates parts of the URI.
 
The encodeURI  and  decodeURI  functions operate on complete URIs; these functions assume that any reserved characters in the URI have special meaning and do not encode them.
The encodeURIComponent  and  decodeURIComponent  functions operate on the individual components that make up a URI; these functions assume that any reserved characters represent normal text, so they must be encoded so that they (reserved characters) when present in the components of a complete URI are not interpreted as Characters are reserved.
 
Note: Chinese characters in the url address of the web page will be automatically transcoded, so if you want to get the Chinese characters in the URL address, you should use decodeURI to decode them

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325269280&siteId=291194637