Encoding problems: it is utf-8. why is the response gbk displayed?

Source: Internet
Author: User
Encoding problem: why is the response gbk displayed when it is UTF-8? Parttime.wengege.comhlogin.html response code: gbk, utf-8.HTTP1.1 & nbsp; 200 & nbsp; OKServer: & nbsp; nginx1.4.1Date: & nbsp; Mon, & nbsp; 09 & nbsp; Jun & nbsp; 2014 & nb Encoding question: it is UTF-8, why is the response displayed as gbk?
Http://parttime.wengege.com/h/login.html

The response encoding is gbk and UTF-8.

HTTP/1.1 200 OK
Server: nginx/1.4.1
Date: Mon, 09 Jun 2014 15:28:28 GMT
Content-Type: text/html; charset = gbk, UTF-8
Content-Length: 1843
Last-Modified: Mon, 09 Jun 2014 15:28:16 GMT
Connection: keep-alive
ETag: "5395d290-733"
Accept-Ranges: bytes

This/login.html content can be opened with editplus as UTF-8. it has been saved as UTF-8 several times.

Where does the browser determine if it is gbk? So as to garbled characters?

------ Solution --------------------
Try another editor, such as Notepad or emeditor.
------ Solution --------------------
Besides the status code, the content in the http header is declared.
If you
Header ('content-type: text/html; charset = gbk, utf-8 ');
Content-Type: text/html; charset = gbk, UTF-8

Default_charset of php. ini
Default_charset of httpd. conf
And so on.
------ Solution --------------------
It is estimated that the server is configured by default.
I can't figure out the problem.

If no code can be properly displayed on the same server, it should be a configuration problem.
If the code that can be normally displayed changes the normal code to the same content of the file, the problem may occur if it is abnormal.
If the text changed to this file can still be normally displayed, use a hexadecimal viewer to compare the two files.
------ Solution --------------------
Nginx configuration problems? Test it with apache?
------ Solution --------------------
After reading the above response, I think of a problem.
Will there be a configuration of. htaccess in this project, and a default charset in. htaccess?
------ Solution --------------------
No
. Htaccess
Adddefacharcharset gbk
Adddefacharcharset UTF-8
The result is Content-Type: text/html; charset = utf-8
That is, only the last command is valid.

However, if
Adddefacharcharset gbk, UTF-8
It is Content-Type: text/html; charset = gbk, UTF-8

So the problem went around again, and the character set declaration was set, not built-in.



Reference:
After reading the above response, I think of a problem.
Will there be a configuration of. htaccess in this project, and a default charset in. htaccess?

------ Solution --------------------
Your js files also contain Content-Type: text/html; charset = gbk, UTF-8
Apparently it's something in the web server configuration file.
You can find the gbk in the server configuration file.

If you really don't want to find it, add it to. htaccess.
Adddefacharcharset UTF-8

This overwrites the original settings.
------ Solution --------------------
Try again when you save it without bom. I caught the packet and found that your html has a bom header.

New discoveries: even browsers with bom headers will be grayed out by selecting the encoding menu?

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.