The Escape () method of JavaScript

Source: Internet
Author: User

Escape () Method:
Encodes the specified string using the ISO Latin character set. All whitespace, punctuation, special characters, and other non-ASCII characters
will be converted to the%XX format character encoding (XX equals the character's encoded 16 digits in the character set table). For example, a space
Code that corresponds to the symbol is%20. The Unescape method is the opposite. Characters that are not encoded by this method: @ */+

Encodeurl () Method: Converts the URL string into an escape format using the UTF-8 encoding format. Words that are not encoded by this method
Character:! @ # $& * () =:/;? +

Encodeurlcomponent () Method: Converts the URL string into an escape format using the UTF-8 encoding format. And
Compared to Encodeurl (), this method encodes more characters, such as characters. So if the string contains a URL
, this method cannot be used to encode, otherwise the URL will display an error after the/character is encoded. Not be compiled by this method
Code of characters:! * ( )

Therefore, for Chinese strings, if you do not want to convert the string encoding format into UTF-8 format (such as the original page and the target page
CharSet is the same time), only need to use escape. If your page is GB2312 or other encoding, and the parameter is accepted
Page is UTF-8 encoded, it is necessary to use Encodeurl or encodeurlcomponent.
In addition, Encodeurl/encodeurlcomponent was introduced after javascript1.5, and escape was in javascript1.0

The Escape () method of JavaScript

Related Article

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.