Home Web Front-end JS Tutorial A brief discussion on JavaScript character sets_Basic knowledge

A brief discussion on JavaScript character sets_Basic knowledge

May 16, 2016 pm 04:47 PM
javascript character set

JavaScript is case-sensitive:

Keywords, variables, function names, and all identifiers must be in consistent upper and lower case (generally we write them in lower case), which is very different from the multi-style writing method when I first learned C#.

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

Copy code The code is as follows:

var str='abc';
var Str ='ABC';
alert(str);//Output abc

A brief discussion on JavaScript character sets_Basic knowledge

If str and Str are the same variable, then alert(str);, the output result should be ABC instead of abc as shown above. This just shows: JavaScript is case-sensitive.

Unicode escape sequence

The emergence of the Unicode character set is to make up for the limitation that ASCII codes can only represent 128 characters. If we want to display Chinese characters and Japanese in daily life, ASCII is obviously impossible. So Unicode is a superset of ASCII and Latin-1. First of all, JavaScript programs are written using the Unicode character set. However, in some computer hardware and software, it is impossible to display or input the complete set of Unicode characters (such as: é). In order to solve this phenomenon, JavaScript defines a special Sequence, this sequence uses 6 ASCII characters to represent any 16-bit Unicode internal code. This special sequence is collectively called the Unicode escape sequence. It is prefixed with u, followed by 4 hexadecimal digits

For example:

Copy code The code is as follows:

var str='cafu00e9';
var Str ='café';
alert(Str ' ' str);// It can be seen that the display effect is the same.
alert (Str===str);//output true

A brief discussion on JavaScript character sets_Basic knowledgeA brief discussion on JavaScript character sets_Basic knowledge

But we should note that Unicode allows multiple methods to encode the same character, as illustrated by the above é escape example:

é:

1. Unicode character u00E9 can be used to represent

2. You can also use eu0301 (intonation character) to represent

Copy code The code is as follows:

var str='cafu00e9';
var Str ='cafeu0301';
alert(str ' ' Str); //As shown in the figure below, the output results of Str and str are the same
alert(Str===str); //The result is The same, but their binary encoding representations are fundamentally different, so the output is false

Although the results displayed on the text editor are the same, their binary encoding representations are fundamentally different. The programming language will eventually be converted into the computer mechanical code (binary encoding) of the local platform, and the computer can only process the binary The result can only be known by comparing the codes, so the final result of their comparison can only be false

So this is the best explanation for "Unicode allows multiple methods to encode the same character", because the Unicode standard defines a preferred encoding format for all characters to convert text into a uniform Unicode format. Sense sequence for appropriate comparison

Using é as an example again:

Are the é in face and café the same?

The é in face and café are both converted to u00E9 or both are converted to eu0301, so that the é in face and café can be compared

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Will R.E.P.O. Have Crossplay?
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to implement an online speech recognition system using WebSocket and JavaScript How to implement an online speech recognition system using WebSocket and JavaScript Dec 17, 2023 pm 02:54 PM

How to use WebSocket and JavaScript to implement an online speech recognition system Introduction: With the continuous development of technology, speech recognition technology has become an important part of the field of artificial intelligence. The online speech recognition system based on WebSocket and JavaScript has the characteristics of low latency, real-time and cross-platform, and has become a widely used solution. This article will introduce how to use WebSocket and JavaScript to implement an online speech recognition system.

WebSocket and JavaScript: key technologies for implementing real-time monitoring systems WebSocket and JavaScript: key technologies for implementing real-time monitoring systems Dec 17, 2023 pm 05:30 PM

WebSocket and JavaScript: Key technologies for realizing real-time monitoring systems Introduction: With the rapid development of Internet technology, real-time monitoring systems have been widely used in various fields. One of the key technologies to achieve real-time monitoring is the combination of WebSocket and JavaScript. This article will introduce the application of WebSocket and JavaScript in real-time monitoring systems, give code examples, and explain their implementation principles in detail. 1. WebSocket technology

How to use JavaScript and WebSocket to implement a real-time online ordering system How to use JavaScript and WebSocket to implement a real-time online ordering system Dec 17, 2023 pm 12:09 PM

Introduction to how to use JavaScript and WebSocket to implement a real-time online ordering system: With the popularity of the Internet and the advancement of technology, more and more restaurants have begun to provide online ordering services. In order to implement a real-time online ordering system, we can use JavaScript and WebSocket technology. WebSocket is a full-duplex communication protocol based on the TCP protocol, which can realize real-time two-way communication between the client and the server. In the real-time online ordering system, when the user selects dishes and places an order

How to implement an online reservation system using WebSocket and JavaScript How to implement an online reservation system using WebSocket and JavaScript Dec 17, 2023 am 09:39 AM

How to use WebSocket and JavaScript to implement an online reservation system. In today's digital era, more and more businesses and services need to provide online reservation functions. It is crucial to implement an efficient and real-time online reservation system. This article will introduce how to use WebSocket and JavaScript to implement an online reservation system, and provide specific code examples. 1. What is WebSocket? WebSocket is a full-duplex method on a single TCP connection.

JavaScript and WebSocket: Building an efficient real-time weather forecasting system JavaScript and WebSocket: Building an efficient real-time weather forecasting system Dec 17, 2023 pm 05:13 PM

JavaScript and WebSocket: Building an efficient real-time weather forecast system Introduction: Today, the accuracy of weather forecasts is of great significance to daily life and decision-making. As technology develops, we can provide more accurate and reliable weather forecasts by obtaining weather data in real time. In this article, we will learn how to use JavaScript and WebSocket technology to build an efficient real-time weather forecast system. This article will demonstrate the implementation process through specific code examples. We

How to use insertBefore in javascript How to use insertBefore in javascript Nov 24, 2023 am 11:56 AM

Usage: In JavaScript, the insertBefore() method is used to insert a new node in the DOM tree. This method requires two parameters: the new node to be inserted and the reference node (that is, the node where the new node will be inserted).

Simple JavaScript Tutorial: How to Get HTTP Status Code Simple JavaScript Tutorial: How to Get HTTP Status Code Jan 05, 2024 pm 06:08 PM

JavaScript tutorial: How to get HTTP status code, specific code examples are required. Preface: In web development, data interaction with the server is often involved. When communicating with the server, we often need to obtain the returned HTTP status code to determine whether the operation is successful, and perform corresponding processing based on different status codes. This article will teach you how to use JavaScript to obtain HTTP status codes and provide some practical code examples. Using XMLHttpRequest

Detailed explanation of how to modify the character set of Oracle database Detailed explanation of how to modify the character set of Oracle database Mar 02, 2024 pm 03:18 PM

Detailed explanation of how to modify the character set of Oracle database Oracle database is a powerful relational database management system that supports multiple character sets, including Simplified Chinese character set, Traditional Chinese character set, English character set, etc. In practical applications, you may encounter situations where you need to modify the database character set. This article will introduce in detail the method of modifying the Oracle database character set and provide specific code examples for readers' reference. 1. Check the current database character set. Before modifying the database character set, you first need to check the current database character set.

See all articles