Escape () string encoding function and other JS encoding functions
Escape (String)
Definitions and usage
The escape () function encodes the string so that it can be read on all computers.
Grammar
Escape (String) parameter description
String required. The string to be escaped or encoded.
1: Note: All spaces, punctuation, accented symbols, and other non-ASCII characters are replaced with%XX encoding, where xx equals the hexadecimal number of that character. For example, a space returns "%20". The character value greater than 255 is encoded in the "%uxxxx" format.
return value
A copy of the encoded string. Some of these characters are replaced with the 16-in escape sequence
2: Characters not encoded:
- _ . ! ~ * ' () @ */+ 0-9 A-Z
3: Note: Escape method has not been recommended, its decoding method Unescape () method has been discarded
encodeURI (String)
Definition and usage
The encodeURI () function encodes a string as a URI.
encodeURI () method is used to convert a string to a URI
Syntax
Grammar
encodeURI (uristring)
1: A string that converts the URI string into an escape format using the UTF-8 encoding format.
2: Characters not encoded:
- ~ ! @ # $ & * () =:/;? + ' 0-9 A-Z
3: Decoding method: decodeURI ()
encodeURIComponent (String)
1: A string that converts the URI string into an escape format using the UTF-8 encoding format. This method encodes more characters than encodeURI (), such as/
2: Characters not encoded:
- ~ ! * () ' 0-9 A-Z
3: Decoding method: decodeURIComponent ()
4: Note: One of the slashes will also be encoded. This will not be valid when the encoding result is sent as a request to the Web server. This method can be used to encode the plus sign of the parameter section to prevent being replaced with a space