About URL encoding conversion-escape (), encodeuri () and encodeuricomponent ()-reprint favorites!

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.