For HTML Chinese garbled characters,
System: ubuntu 14.04
Software: bluefish
I. Reasons for garbled characters
1. Mixed content of different codes: HTML garbled characters are generated due to html Encoding Problems (Common gb2312 and UTF-8 encoding contents exist at the same time)
2. HTML encoding not set:
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>Not set. UTF-8 is set here
3. Use notepad to edit html: Using notepad to directly edit html is also prone to html encoding garbled characters.
2. Solutions
Add the following code to the HTML file header:
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
Iii. Supplement:
We usually use three charset values: gb2312, gbk, and UTF-8. Which one should we set? Why do Chinese garbled characters still occur when we have added this line of code?
Because we ignore one thing, that is, the actual encoding method of HTML files,
If the actual encoding method of the HTML file is the same as that set by charset, no HTML Chinese garbled characters will occur,
If it is different, there may be Chinese garbled characters, but there are exceptions: if the actual encoding is UTF-8, 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: ensure that the actual encoding method of the HTML file is the same as that set by charset. Of course, the encoding method must be supported by the system, which is the most basic.
The above is Baidu's own summary, only this record.