JavaScript processes Chinese characters for Computer Recognition and reading

Source: Internet
Author: User
Tags encode string

Js converts a string to a specific encoding so that it can be recognized and read by any computer:

1. escape Method
Encode String objects so that they can be read on all computers,
Escape (charString)
The required charstring parameter is any String object or text to be encoded.
Note:
The escape method returns a string containing the charstring content (in Unicode format ). All spaces, punctuation marks, and accents are replaced by % xx encoding and other non-ASCII characters. xx indicates the hexadecimal number of the character. For example, "% 20" is returned by a space ". The characters with a value greater than 255 are stored in % uxxxx format.

Note: The escape method cannot be used to encode uniform resource identifiers (URIs. Use the encodeURI and encodeURIComponent methods for encoding.

2. unescape Method

Decodes String objects encoded using the escape method.
Unescape (charstring)
The required charstring parameter is the String object to be decoded.

Note:
The unescape method returns a string value containing charstring content. All characters encoded in % xx hexadecimal format are replaced by characters of medium price in the ASCII character set. Characters encoded in % uxxxx format (Unicode character) are replaced by Unicode characters encoded in hexadecimal format xxxx.
Note: The unescape method cannot be used to decode a Uniform Resource Identifier (URI ). The decodeURI and decodeURIComponent methods can be used to decode this code.

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.