编码问题:明明是utf-8,为何显示响应为gbk呢?
http://parttime.wengege.com/h/login.html
响应编码居然为:gbk,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
此/login.html内容用editplus打开看为utf-8.也已经另存为好几次为utf-8了。
是哪里让浏览器判断是gbk了呢?从而乱码?
回复讨论(解决方案)
Content-Type: text/html; charset=gbk,utf-8 ???
有这样做字符集声明的吗?
浏览器如何知道哪些是 gbk 的,哪些是 utf-8 的?
换一个编辑器试试,比如记事本或者emeditor之类的
Content-Type: text/html; charset=gbk,utf-8 ???
有这样做字符集声明的吗?
浏览器如何知道哪些是 gbk 的,哪些是 utf-8 的?
这也正是我要问的问题。
上面的不是声明,是http响应。
换一个编辑器试试,比如记事本或者emeditor之类的
我换了几个编辑器保存了。里面有GBK字符。所以将utf-8识别为gbk了。真是奇怪了。
本人研究编码整整10年了。从来还没有编码搞不定的问题。
上面问题只在linux上出现,windows下无法重现。
而且,我换到其它test目录。则内容完好显示。
http 头中的内容除了状态码都是声明啊
如果你
header('Content-type: text/html;charset=gbk,utf-8');
HTTP 投中就会有 Content-Type: text/html;charset=gbk,utf-8
php.ini 的 default_charset
httpd.conf 的 default_charset
等,都是可以设置的
估计是服务器默认配置了
实在想不出到底哪里有问题
如果同一台服务器上没有能正常显示的代码,那应该是配置问题。
如果有能正常显示的代码 把正常的代码改成这文件相同的内容,不正常看改了那句出问题
改成这个的文本还能正常显示的话用16进制查看器对比一下两个文件
估计是服务器默认配置了
实在想不出到底哪里有问题
如果同一台服务器上没有能正常显示的代码,那应该是配置问题。
如果有能正常显示的代码 把正常的代码改成这文件相同的内容,不正常看改了那句出问题
改成这个的文本还能正常显示的话用16进制查看器对比一下两个文件
我服务器上其它码没有问题。
而且,
我将此文件移动个目录就可以正常访问了。。。。
http://parttime.wengege.com/h/test.html
上面连接也是,在chrome下有乱码(JS引入时有乱码,奇怪的是其它部分乱码好了)。在ie下完全正常。
nginx的配置问题?换apache测试一下?
结论是不言而喻的
login 模板文件是utf-8编码,但php程序header声明或服务器默认配置输出的响应头是gbk, utf-8,就会出现webkit和chrome乱码,而IE正常
test 模板文件本身是gb2312编码,响应头仍然是gbk, utf-8,就会出现9楼的情况
我猜想,webkit和chrome识别编码,响应头优先于DOM中header声明,而IE恰好相反
我看到楼主服务器上的js文件响应头charset都是gbk,utf-8,应该是服务器默认输出的问题了
看完以上的回?,想到一???。
?不?在??目?有?置.htaccess,在.htaccess中?置了default charset呢?
结论是不言而喻的
是的,GBK哪来的?关键是GBK哪来的?版主。亲爱的。方向搞错了。我也在思考,GBK到底是从哪来的?
我知道问题出现在GBK上面。GBK是结果,而不是开头。
看完以上的回?,想到一???。
?不?在??目?有?置.htaccess,在.htaccess中?置了default charset呢?
昨天就检查过了,没有发现。htaccess文件中有编码问题。
login 模板文件是utf-8编码,但php程序header声明或服务器默认配置输出的响应头是gbk, utf-8,就会出现webkit和chrome乱码,而IE正常
test 模板文件本身是gb2312编码,响应头仍然是gbk, utf-8,就会出现9楼的情况
我猜想,webkit和chrome识别编码,响应头优先于DOM中header声明,而IE恰好相反
我看到楼主服务器上的js文件响应头charset都是gbk,utf-8,应该是服务器默认输出的问题了
没有找到任何地方有header问题。同时没有login模板。这就是普通的html,不是什么模板。多谢关注。
不会
.htaccess 中
AddDefaultCharset gbk
AddDefaultCharset utf-8
则结果是 Content-Type: text/html; charset=utf-8
即只有最后一条指令有效
倒是,如果
AddDefaultCharset gbk,utf-8
那么就是 Content-Type: text/html; charset=gbk,utf-8 了
于是问题又绕回去了,字符集声明是设定的,而不是内置的
看完以上的回?,想到一???。
?不?在??目?有?置.htaccess,在.htaccess中?置了default charset呢?
现在问题是:所有文件都检查过了(css,php,js),确定为utf-8编码。
有几个问题搞不定:
一、普通的html为utf-8编码。http响应居然为gbk,utf-8.所以出现乱码。问题是gbk哪来的?这三个字符哪来的?
我已经全站搜索GBK这三个字符。无获!!!
二、就算html偶尔成功后,但引入js还是乱码。指定引入编码为utf-8.
三、通过w3c烂网站检查,“成功识别”编码依然为 “gbk”. 然后w3c网站无数次崩溃。
真是神奇,检查结果说某行有问题。所有字符我从新打过,还是如此。换个目录的文件thinkphp3.1的登录还是正常。而thinkphp3.2下运行此html就是不正常。关键是这html和thinkphp毛关系都扯不上啊?
你的 js 文件也有 Content-Type: text/html; charset=gbk,utf-8
显然是 web 服务器配置文件里面的事情了
你在服务器配置文件中找 gbk 字样,应该就能找到的
实在不想找的话,就在 .htaccess 中加入
AddDefaultCharset utf-8
这有覆盖了原有的设置了
你保存时选无bom再试试,我抓包发现你的html有bom头
新发现:有bom头居然导致偶的浏览器,选择编码的菜单变灰?
没有找到任何地方有header问题。同时没有login模板。这就是普通的html,不是什么模板。多谢关注。
html和模板同理啊~我猜测出了2个问题的原因,IE一直坚挺不乱(响应头和DOM编码声明的优先级不同),还有为什么test正文反而不乱了(也许test.html文件是gbk编码而login.html是utf-8),另外你说:我换到其它test目录,则内容完好显示。会不会也是文件变成了gbk编码的原因?至于最关键的为什么响应头有gbk超出我知识范围了,关注学习一下
问题原因找到,是nginx此网站配置时使用了charset gbk,utf-8 这样设置了。去掉gbk就ok了。所以乱码解决。
问题原因找到,是nginx此网站配置时使用了charset gbk,utf-8 这样设置了。去掉gbk就ok了。所以乱码解决。
一开始在10楼就提出配置问题,微弱的存在感被无视了
而且,我换到其它test目录。则内容完好显示。
被?句??了。
?目?,??都是?出??的。因?default charset是gbk,utf8.
亲,你说的nginx配置,太大了。我指的配置是指此虚拟主机的配置。此nginx上有好多个网站,其它没有问题的。
问题原因找到,是nginx此网站配置时使用了charset gbk,utf-8 这样设置了。去掉gbk就ok了。所以乱码解决。
一开始在10楼就提出配置问题,微弱的存在感被无视了
而且,我换到其它test目录。则内容完好显示。
被?句??了。
?目?,??都是?出??的。因?default charset是gbk,utf8.
换目录后,不知道咋加上bom头了,所以可以了。
亲,你说的nginx配置,太大了。我指的配置是指此虚拟主机的配置。此nginx上有好多个网站,其它没有问题的。
其他网站没事,12楼就提到js文件响应头就是gbk,utf-8,瞬间可以锁定目标啊~
你们研究半天php脚本和BOM,新人难得蒙对一次 怨念的看着你们

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

When you click the search field in Windows 11, the search interface automatically expands. It displays a list of recent programs on the left and web content on the right. Microsoft displays news and trending content there. Today's check promotes Bing's new DALL-E3 image generation feature, the "Chat Dragons with Bing" offer, more information about dragons, top news from the Web section, game recommendations, and the Trending Search section. The entire list of items is independent of your activity on your computer. While some users may appreciate the ability to view news, all of this is abundantly available elsewhere. Others may directly or indirectly classify it as promotion or even advertising. Microsoft uses interfaces to promote its own content,

Microsoft's Windows 11 operating system may periodically display suggestions as pop-ups on your computer using the notification system. The suggestions system, originally intended to provide users with tips and suggestions for improving their Windows 11 workflows, has almost completely transformed into an advertising system to promote Microsoft services and products. Suggestion pop-ups might advertise a Microsoft 365 subscription to users, suggest linking an Android phone to the device, or set up a backup solution. If these pop-ups annoy you, you can tweak your system to disable them entirely. The following guide provides recommendations on disabling pop-ups on devices running Microsoft’s Windows 11 operating system.

What happens when the desktop layout is locked? When using the computer, sometimes we may encounter the situation where the desktop layout is locked. This problem means that we cannot freely adjust the position of desktop icons or change the desktop background. So, what exactly is going on when it says that the desktop layout is locked? 1. Understand the desktop layout and locking functions. First, we need to understand the two concepts of desktop layout and desktop locking. Desktop layout refers to the arrangement of various elements on the desktop, including shortcuts, folders, widgets, etc. we can be free

Large language models (LLMs) have the ability to generate smooth and coherent text, bringing new prospects to areas such as artificial intelligence conversation and creative writing. However, LLM also has some key limitations. First, their knowledge is limited to patterns recognized from training data, lacking a true understanding of the world. Second, reasoning skills are limited and cannot make logical inferences or fuse facts from multiple data sources. When faced with more complex and open-ended questions, LLM's answers may become absurd or contradictory, known as "illusions." Therefore, although LLM is very useful in some aspects, it still has certain limitations when dealing with complex problems and real-world situations. In order to bridge these gaps, retrieval-augmented generation (RAG) systems have emerged in recent years. The core idea is

Go language encoding analysis: UTF-8 and GBK comparison In the Go language, processing string encoding is one of the common tasks. Among them, UTF-8 and GBK are two commonly used character encoding methods. This article will conduct a detailed comparison between UTF-8 and GBK, discuss their differences and usage, and attach specific code examples. 1. Introduction to UTF-8 and GBK UTF-8: UTF-8 is a variable-length Unicode encoding method that can represent characters in almost all languages in the world. UTF-8

Common encoding methods include ASCII encoding, Unicode encoding, UTF-8 encoding, UTF-16 encoding, GBK encoding, etc. Detailed introduction: 1. ASCII encoding is the earliest character encoding standard, using 7-bit binary numbers to represent 128 characters, including English letters, numbers, punctuation marks, control characters, etc.; 2. Unicode encoding is a method used to represent all characters in the world The standard encoding method of characters, which assigns a unique digital code point to each character; 3. UTF-8 encoding, etc.

There are many users using Remote Desktop Connection. Many users will encounter some minor problems when using it, such as the other party's taskbar not being displayed. In fact, it is probably a problem with the other party's settings. Let's take a look at the solutions below. How to display the other party's taskbar during Remote Desktop Connection: 1. First, click "Settings". 2. Then open "Personalization". 3. Then select "Taskbar" on the left. 4. Turn off the Hide Taskbar option in the picture.

In Linux systems, you can use the pwd command to display the current path. The pwd command is the abbreviation of PrintWorkingDirectory and is used to display the path of the current working directory. Enter the following command in the terminal to display the current path: pwd After executing this command, the terminal will display the full path of the current working directory, such as: /home/user/Documents. In addition, you can use some other options to enhance the functionality of the pwd command. For example, the -P option can display
