Table of Contents
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
Copy after login
" >TOP
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
Copy after login
Home Web Front-end HTML Tutorial Detailed explanation of language encoding of charset in html

Detailed explanation of language encoding of charset in html

Jul 22, 2017 pm 01:31 PM
charset html coding

Pay attention to the importance of HTML language encoding

  • Directory


  1. ##Importance of charset encoding

  2. Where is charset in html

  3. charset tag

  4. Encoding type

  5. charset utf-8 introduction

  6. Introduction to charset GB2312

  7. Recommended web page encoding

  8. Web page compatibility due to encoding

1. The importance of encoding -

TOP

Encoding can cause garbled web pages when viewers use IE, and can also cause p+css compatibility Hack.

2. Encoding position -

TOP

3. HTML encoding style -

TOP
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
Copy after login

By changing The utf-8 in charset=utf-8 can change the encoding of the web page.
Generally when we write a CSS file, 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.

4. Commonly used html encoding types -

TOP

The two 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.

5. UTF-8 has the following characteristics: -

TOP

    ##UCS characters U+0000 to U+007F (ASCII) are encoded as Bytes 0x00 to 0x7F (ASCII compatible). This means that files containing only 7-bit ASCII characters are the same in both ASCII and UTF-8 encodings.
  1. All> The UCS character ;U+007F is encoded as a string of multiple bytes, each with a set of flag bits. Therefore, the ASCII bytes (0x00-0x7F) cannot be part of any other character.
  2. The first byte of a multi-byte string representing a non-ASCII character is always in the range 0xC0 to 0xFD, and indicates how many bytes this character contains. The rest of the multi-byte string Bytes are all in the range 0x80 to 0xBF. This makes resynchronization very easy, and makes the encoding borderless and rarely affected by missing bytes.
  3. Can encode all possible The 231 UCS codes
  4. UTF-8 encoded characters can theoretically be up to 6 bytes long, but 16-bit BMP characters can only be up to 3 bytes long.
  5. Bigendian UCS-4 byte strings are arranged in a predetermined order.
  6. Bytes 0xFE and 0xFF are never used in UTF-8 encoding .
  7. 6. GB2312 has the following characteristics -
TOP

GB2312 standard contains a total of 6763 Chinese characters, including 3755 first-level Chinese characters and second-level Chinese characters. There are 3008 Chinese characters; at the same time, GB2312 includes 682 full-width characters including Latin letters, Greek letters, Japanese hiragana and 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 so that 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" is 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.

7. Recommended charset encoding -

TOP

##UTF-8 can be easily understood. Simplified and Traditional Chinese can use this encoding. For example, Taiwan and Mainland China use this encoding. .

8. Web page compatibility errors caused by encoding: - TOP

#If the encoding is mixed, the web page will be garbled, which is also called incompatible, especially if encoding mixing is used in CSS comments row will result in css hack.

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

Users who have viewed this page have also viewed the following content:
1. The differences and relationships between UTF-8 GBK UTF8 GB2312
2. How to choose html encoding
3. html encoding settings

The above is the detailed content of Detailed explanation of language encoding of charset in 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

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)

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.

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

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 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