Escape () string encoding function and other JS encoding functions

Source: Internet
Author: User

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

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.