JavaScript Character Set

Source: Internet
Author: User

JavaScriptIs case sensitive:

Keywords, variables, function names, and all identifiers must use the same case (generally we write them in lower case ), this is very different from C #'s simplified writing method.

For example: (Here we use the str and Str variables as examples)

1 var str = 'abc'; 2 3 var Str = 'abc'; 4 5 alert (str); // output abc

 

If str and Str are the same variables, then alert (str);, the output result should be ABC rather than abc, as shown in. This exactly shows that JavaScript is case sensitive.

 

Unicode escape sequence

The Unicode character set is used to make up for the limit that the ASCII code can only represent 128 characters. in daily life, if we want to display Chinese characters and Japanese characters, it is obviously impossible to use ASCII. Unicode is a superset of ASCII and Latin-1. First of all, JavaScript programs are written in the Unicode Character Set, but in some computer hardware and software, it is impossible to completely display or enter the full set of Unicode characters (For example:ÉTo solve this problem, JavaScript defines a special sequence, which uses six ASCII characters to represent any 16-bit Unicode Internal Code. These special sequences are collectively called Unicode escape sequences,It uses\ UIs the prefix, followed4Hexadecimal number

For example:

1 var str = 'caf \ u00e9 ';
2 var Str = 'CA ';
3 alert (Str + ''+ str); // you can see that the results are the same.
4 alert (Str = str); // Output true


However, we should note that Unicode allows multiple methods to encode the same character. The preceding e-escape example is used to describe the following:

É:

1.AvailableUnicodeCharacter\ U00E9Indicates

2.E \ u0301 (Tone character)Indicates

1 var str = 'caf \ u00e9 ';
2 var Str = 'cafe \ u0301 ';
3 alert (str + ''+ Str); // As shown in, the output results of Str and str are the same.
4 alert (Str = str); // The result is the same, but their binary code representation is different, so false is output.

Although the results displayed in the text editor are the same, their binary code representation is basically different, and the programming language will eventually convert to the computer mechanical code (Binary Code) of the local platform ), the computer can only know the result by comparing the binary encoding. Therefore, the final result for comparing them can only be false.

Therefore, this is the best explanation of "Unicode allows multiple methods to encode the same character, the Unicode Standard defines a preferred encoding format for all characters to facilitate the conversion of text into Unicode escape sequences in a unified format for appropriate comparison

Take é again as an example:

ComparisonFacéAndCaféInÉAre they the same?

Both fac é and caf é can be converted to \ u00E9 or both can be converted to e \ u0301 to compare the files in fac é and caf é.

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.