URL encoding conversion, escape () encodeuri () encodeuricomponent ()
Escape () method:
The specified string is encoded using the ISO Latin character set. All space characters, punctuation marks, special characters, and other non-ASCII characters will be converted into character encoding in % XX format (XX equals to the hexadecimal encoding of this character in the character set table number ). For example, the space character is encoded as % 20. The Unescape method is the opposite. Characters not encoded by this method: @ */+
Msdn JScript reference: the escape method returns a string value (in unicode format) that contains the contents of [the argument]. all spaces, punctuation, accented characters, and any other non-ASCII characters are replaced with % XX encoding, where XX is equivalent to the hexadecimal number representing the character. for example, a space is returned as "% 20."
Edge core JavaScript guide: the escape and Unescape functions let you encode and decode strings. the escape function returns the hexadecimal encoding of an argument in the ISO Latin character set. the Unescape function returns the ASCII string for the specified hexadecimal encoding value.
Encodeuri () method:
Convert a URI string to an escape string in UTF-8 encoding format. Characters not encoded by this method :! @ # $ & * () = :/;? +'
Msdn JScript reference: The encodeuri method returns an encoded Uri. if you pass the result to decodeuri, the original string is returned. the encodeuri method does not encode the following characters: ":", "/", ";", and "? ". Use encodeuricomponent to encode these characters. edge core JavaScript guide: encodes a Uniform Resource Identifier (URI) by replacing each instance of certain characters by one, two, or three escape sequences representing the UTF-8 encoding of the character
Encodeuricomponent () method:
Convert a URI string to an escape string in UTF-8 encoding format. Compared with encodeuri (), this method will encode more characters, such. Therefore, if the string contains several parts of the URI, this method cannot be used for encoding. Otherwise, the URL will display an error after the/character is encoded. Characters not encoded by this method :! *()
Msdn JScript reference: The encodeuricomponent method returns an encoded Uri. if you pass the result to decodeuricomponent, the original string is returned. because the encodeuricomponent method encodes all characters, be careful if the string represents a path such as/folder1/folder2/default.html. the slash characters will be encoded and will not be valid if sent as a request to a Web server. use the encodeuri method if the string contains more than a single URI component. mozilla developer core JavaScript guide: encodes a Uniform Resource Identifier (URI) component by replacing each instance of certain characters by one, two, or three escape sequences representing the UTF-8 encoding of the character.