HTML reading has garbled characters, what is the reason for HTML garbled characters?

In web pages, we sometimes see a large string of Chinese garbled characters, so what is the reason for HTML garbled characters? How to deal with it? The following article will introduce to you the causes and solutions of HTML Chinese garbled characters, hoping to help you.

00f7b95189a2dd99062be163491396f0.png

HTML garbled reasons

1. The content of different encodings is mixed:

HTML is garbled because of html encoding problems (commonly, gb2312 and utf-8 encoding content exists at the same time)

2. The HTML encoding is not set:

Example: utf-8 is not set

3. Use notepad to edit html:

Sometimes using Notepad to edit html directly, it will also be garbled in html encoding.

Solution

Add the following code to the HTML file header:

Replenish:

The settings of charset we often use are gb2312, gbk, and utf-8. Which should it be? Why sometimes we have added this line of code and still have Chinese garbled characters?

Because we overlooked one thing. That's how the HTML file is actually encoded,

Assuming that the actual encoding method of the HTML file is the same as that set by charset, there will be no HTML Chinese garbled problem.

If the assumptions are different, Chinese garbled characters may appear. But there are exceptions: assuming the actual encoding is utf-8. Then charset is set to uft-8 or gbk will not be garbled, the reason is not clear.

The key to avoiding HTML Chinese garbled characters: Make sure that the actual encoding method of the HTML file is consistent with the encoding method set by charset. Of course, the set encoding method must be supported by the system, which is the most important.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=324126363&siteId=291194637