About the irritability of the page coding problem utf-8,gb2312. I finally practiced it all over again

Source: Internet
Author: User

As the saying goes, practice is the only standard to test truth, indeed.

Oneself has been relatively lazy, although I think Daniel should be a notepad all done, but I still like to use DW or vs to write a good web page architecture, because always feel with Notepad also want to import the statement, and Gvim has not used handy, So today in the down of a foreign jquery design, their own changes, the problem arises.

down down the document CHARSET=UTF-8, so I changed my hand to become a gb2312, the result of the cup has come, I added all the Chinese garbled, the heart of anger on the burning, have encountered coding problems before, But every time the text adjusted correctly after the reason, but today is really unbearable, it took an afternoon time, I think about this problem, now calculate a little harvest.

Let's start by explaining the four ways that Notepad is saved as a code.

1.ANSI (default): The ANSI encoding method in Chinese environment is our familiar GB2312

2.Unicode: UTF-16

3.unicode big endian: Get a half-day still do not understand, only know is and UTF in encoding when there are sequential differences.

4.utf-8: The famous international General UTF-8, personally think it should be a trend. Because in the Web environment, style can be personality, changeable, but the rules should be unified.

Test environment: Firefox,ie,chrome,opera.

First I created six HTML pages, all built with Notepad. Choose GB2312 (that is, ANSI) and UTF-8 two ways to save as a test.

1. Save with GB2312 (ANSI) and declare charset=gb2312.

Result: normal display.

2. Save with GB2312 (ANSI) and declare charset=utf-8.

Result: garbled.

3. Save with UTF-8 and declare charset=utf-8.

Result: normal display.

4. Save with UTF-8 and declare charset=gb2312.

Results: Other normal display, only Firefox garbled.

5. Save with GB2312 (ANSI), but do not declare charset.

Result: normal display.

6. Save with UTF-8, but do not declare charset.

Result: normal display.

Summary: I think the charset attribute is defined for the browser to accept, the browser will be directly from the CharSet received encoding method to display the Web page, if not declared, the browser will detect how the page encoding. 4th more special, with UTF-8 save but declare charset=gb2312, view browser encoding method is automatically changed to UTF-8, only Firefox is GB2312, here I guess it is because Firefox itself only detects the relationship of CharSet attribute, Other browsers should detect encoding and charset-side properties.

In general, it is important to maintain consistency between the two.

Other sites are also two kinds of statements have, Baidu, QQ are charset=gb2312,google,csdn are UTF-8, I think this is the Gap bar ...

haha haha ^_^

The Problem of Web page coding for irritability is utf-8,gb2312. I finally practiced it all over again

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.