Home Web Front-end HTML Tutorial What are the language encodings of HTML?

What are the language encodings of HTML?

Nov 23, 2017 pm 04:10 PM
html Which language

In HTML, encoding can cause the webpage to be garbled when the viewer passes IE, and can also cause compatibility Hack of div+css. Encoding is very important. Generally, the encoding position is placed in the <head of the HTML page. >Between . Today we will introduce some knowledge about coding.

Generally, this webpage encoding is placed between and in the html webpage.

htmlEncoding style

Pass Changing the utf-8 in charset=utf-8 can change the encoding of the web page.

Generally when we write CSS files, we also need to use @charset "utf-8"; at the top of the CSS file to define the encoding type of this CSS file. Generally, the HTML source code and CSS file encoding must be unified. If they are not unified, it will lead to compatibility issues such as CSS hacks, garbled pages, and chaotic page layout.

Commonly used HTML encoding types

The two most popular ones commonly used in China are utf-8 and gb2312. Generally, these two types can meet domestic web page encoding needs. Of course, these two encoding types are also used in programs and databases to process web pages and store data types.

UTF-8 has the following properties

UCS characters U+0000 to U+007F (ASCII) are encoded as bytes 0x00 to 0x7F (ASCII compatible). This means that only 7 bits are included ASCII character files are the same in both ASCII and UTF-8 encoding methods.

All >U+007F UCS characters are encoded as a multi-byte string, each byte There is a set of flag bits. Therefore, ASCII bytes (0x00-0x7F) cannot be part of any other character.

The first byte of a multi-byte string representing a non-ASCII character is always between 0xC0 and is in the range 0xFD, and indicates how many bytes this character contains. The remaining bytes of a multibyte string are in the range 0x80 to 0xBF. This makes resynchronization very easy, and makes the encoding borderless and less susceptible to missing words. The impact of sections.

Can encode all possible 231 UCS codes

UTF-8 encoded characters can theoretically be up to 6 bytes long, however 16-bit BMP characters can only be to 3 bytes long.

The arrangement order of Bigendian UCS-4 byte strings is predetermined.

Bytes 0xFE and 0xFF are never used in UTF-8 encoding.

GB2312 has the following characteristics

GB2312 standard contains a total of 6763 Chinese characters, including 3755 first-level Chinese characters and 3008 second-level Chinese characters; at the same time, GB2312 includes Latin letters, Greek letters, and Japanese hiragana. and 682 full-width characters including katakana letters and Russian Cyrillic letters.

The emergence of GB2312 basically meets the computer processing needs of Chinese characters. The Chinese characters it contains have covered 99.75% of the frequency of use. In GB2312, the collected Chinese characters are "partitioned", and each zone contains 94 Chinese characters/symbols. This representation is also called location code.

01-09 area contains special symbols.

Areas 16-55 are first-level Chinese characters, sorted by pinyin.

Areas 56-87 are second-level Chinese characters, sorted by radical/stroke.

Districts 10-15 and 88-94 are not coded.

For example, the character "ah" is the first Chinese character in GB2312, and its location code is 1601. In programs using GB2312, the byte structure usually uses the EUC storage method to be compatible with ASCII. Each Chinese character and symbol is represented by two bytes. The first byte is called the "high byte" and the second byte is called the "low byte". The "high byte" uses 0xA1-0xF7 (add 0xA0 to the area code of area 01-87), and the "low byte" uses 0xA1-0xFE (add 01-94 to 0xA0). For example, the word "Ah" will be stored as 0xB0A1 in most programs. (Compare with location code: 0xB0=0xA0+16, 0xA1=0xA0+1).

So the decimal system of the Chinese character area code in GB2312 encoding is from 176 to 247, and the bit code is from 161 to 255. The reason why the stored 6763 is less than 82*94=6768 is because the area code is 215, and the bit code is from 161 to 255. There are five codes between 250 and 254 without Chinese character coding, so 6768-5=6763.

GB2312 encoding can be understood as a common language in China.

Recommended charset encoding

UTF-8 can be easily understood. Simplified and Traditional Chinese can use this encoding, such as Taiwan and Mainland China.

Web page compatibility errors caused by encoding

If the encoding is mixed, the web page will be garbled, which is also called incompatible, especially in CSSCommentsIf the encoding is mixed, it will be Causes css hack.

I hope you will never forget to declare the web page encoding when making web pages in the future.

The above is the knowledge of HTML language encoding. For more exciting information, please pay attention to php Chinese website Other related articles!

Related content:

How to know what CSS property style to set for DIV?

Why do we need to set CSS styles on DIV?

How to use the

tag of html

The above is the detailed content of What are the language encodings of HTML?. For more information, please follow other related articles on the PHP Chinese website!

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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

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)

Table Border in HTML Table Border in HTML Sep 04, 2024 pm 04:49 PM

Guide to Table Border in HTML. Here we discuss multiple ways for defining table-border with examples of the Table Border in HTML.

HTML margin-left HTML margin-left Sep 04, 2024 pm 04:48 PM

Guide to HTML margin-left. Here we discuss a brief overview on HTML margin-left and its Examples along with its Code Implementation.

Nested Table in HTML Nested Table in HTML Sep 04, 2024 pm 04:49 PM

This is a guide to Nested Table in HTML. Here we discuss how to create a table within the table along with the respective examples.

HTML Table Layout HTML Table Layout Sep 04, 2024 pm 04:54 PM

Guide to HTML Table Layout. Here we discuss the Values of HTML Table Layout along with the examples and outputs n detail.

HTML Input Placeholder HTML Input Placeholder Sep 04, 2024 pm 04:54 PM

Guide to HTML Input Placeholder. Here we discuss the Examples of HTML Input Placeholder along with the codes and outputs.

Moving Text in HTML Moving Text in HTML Sep 04, 2024 pm 04:45 PM

Guide to Moving Text in HTML. Here we discuss an introduction, how marquee tag work with syntax and examples to implement.

HTML Ordered List HTML Ordered List Sep 04, 2024 pm 04:43 PM

Guide to the HTML Ordered List. Here we also discuss introduction of HTML Ordered list and types along with their example respectively

HTML onclick Button HTML onclick Button Sep 04, 2024 pm 04:49 PM

Guide to HTML onclick Button. Here we discuss their introduction, working, examples and onclick Event in various events respectively.

See all articles