The js string and Unicode encoding convert each other, And the js string unicode

Source: Internet
Author: User

The js string and Unicode encoding convert each other, And the js string unicode

'Ha'. charCodeAt (0). toString (16) "597d"

This code indicates converting the character 'hao' into Unicode encoding,

Let's see what charCodeAt () means.

The charCodeAt () method returns the Unicode encoding of characters at the specified position. The returned value is an integer between 0 and 65535.

It is equal to a single character in 'charcodeat,

'Good. 'charCodeAt (0). toString (16) "597d" 'Good.' charCodeAt (1). toString (16) "54e6"

The code above shows that you want to know the encoding of a single character by using this parameter, that is, the index.

What if I want to decode unicode into characters?

To decode Unicode, you must use the Escape Character '\ U'

'\ U54e6' "Oh"

After unicode and character escape

Let's talk about the substantive concept.

Js unicode is a string prefixed with a hexadecimal code plus a \ u table. \ Unnnn

Unicode is generated to address the limitations of traditional character encoding schemes. It sets a uniform and unique binary encoding for each character in each language, to meet the requirements of cross-language and cross-platform text conversion and processing. R & D started in December 1990 and officially announced in December 1994. [1]

The above is all the content of this article. I hope this article will help you in your study or work. I also hope to provide more support to the customer's home!

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.