For HTML Chinese garbled characters,

Source: Internet
Author: User

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.




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.