Home  >  Article  >  Web Front-end  >  How to deal with garbled Chinese characters in html5

How to deal with garbled Chinese characters in html5

醉折花枝作酒筹
醉折花枝作酒筹Original
2021-06-08 10:48:582527browse

Solution: 1. Open the html file in the software, select "Modify" - "Page Properties" at the top of the page, select "Title/Encoding" in the new window, select the specified encoding, and click "Apply" and "OK" is enough. 2. Do not use Notepad to edit html code directly.

How to deal with garbled Chinese characters in html5

The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.

1. Reasons for garbled codes

1. Mixed content of different encodings: HTML garbled codes are caused by html encoding problems (common gb2312 and utf-8 encoding contents exist at the same time)

2. HTML encoding is not set: Not set, the setting here is utf-8

3. Use Notepad to edit html: Using Notepad to edit html directly can easily result in html encoding garbled code

2. Methods to solve html garbled code

1. HTML encoding is not set

How to deal with garbled Chinese characters in html5

htmlNo encoding declaration tag

After opening the HTML in the DW software, in the "code" or "split" mode (this way you can see the code Encoding statement appears), click "Modify" and then click "Page Properties"

How to deal with garbled Chinese characters in html5

Select "Title/Encoding" in the pop-up "Page Properties" tab, and then correspond Select the required encoding value in "Encoding" on the right.

How to deal with garbled Chinese characters in html5

Select html encoding screenshot

After selecting HTML encoding, click "Apply" and finally "OK"

How to deal with garbled Chinese characters in html5

Apply the selected HTML encoding

Follow the above steps to add the encoding statement to HTML.

How to deal with garbled Chinese characters in html5

#html coding to add the above screenshot

html No coding to add coding using DW software. Under normal circumstances, do not manually add this line of encoding declaration label in Notepad, otherwise it is likely that the entire html encoding has not changed with the addition of encoding, and the html garbled problem will still exist.

2. Notepad editing html

Generally avoid garbled characters. Remember not to use Notepad directly to edit Html code, because it is easy to cause coding problems and lead to garbled Chinese html, especially the original HTML is encoded in UTF, and after adding Chinese characters or codes in Notepad, garbled characters appear when saving. This is because Notepad directly modifies the code, especially after adding Chinese. The added part is gbk encoded content, while the original content is utf encoded. If the two encoded contents exist at the same time in an Html, it will cause garbled code. Although we cannot distinguish the encoding with the naked eye, this encoding format pattern does exist, so the solution to the problem of garbled encoding is to use DW software to edit and modify it. This can greatly reduce the problem of garbled characters. (How to choose gb2313 utf-8) Recommended learning:

html video tutorial######

The above is the detailed content of How to deal with garbled Chinese characters in html5. For more information, please follow other related articles on the PHP Chinese website!

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