简体   繁体   English

IE9编码问题

[英]IE9 encoding problem

In one of my asp.net-applications I found a strange behaviour produced in Internet Explorer 9 while IE8 works well. 在我的一个asp.net应用程序中,我发现Internet Explorer 9产生了一种奇怪的行为,而IE8却运行良好。

As the default encoding I need utf-8. 作为默认编码,我需要utf-8。 That's important because I use german so called Umlaute like "ÄäÖüÜü". 这很重要,因为我使用的是像ÄäÖüÜü这样的德语所谓的Umlaute。

When the page is loaded for the first time IE9 decides to use "Western Europe" Encoding. 首次加载页面时,IE9决定使用“西欧”编码。 That's ISO 8859-1 as far as I know and the Umlaute change to strange letters. 据我所知,这就是ISO 8859-1,Umlaute变成了奇怪的字母。 On the second load IE9 uses utf-8 correctly. 在第二次加载时,IE9正确使用utf-8。 In the sourcecode I tried the following things to tell IE which encoding to use: 在源代码中,我尝试了以下操作来告诉IE使用哪种编码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 TRANSITIONAL//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="de">
<meta http-equiv="content-type" content="text/html; charset=utf-8">

Why does IE9 work so strange on the first load? IE9为什么在第一次加载时就这么奇怪? And what else can I try to tell IE9 how to work 我还能尝试告诉IE9如何工作

Firstable - server where you host your site can return wrong encoding information in header; Firstable-您托管网站的服务器可能在标头中返回错误的编码信息;

Two - maybe it's some fail in string that tolk about encoding in the header of your page (wrong symbol in that string). 二-可能是字符串中的某些错误导致页面标题中的编码丢失(该字符串中的错误符号)。

Three - open you page in Hex brouser (WinHex for example) and post first row of code (sometimes editor place wrong data in first byte, I've stumble on it once) 三-在Hex brouser(例如WinHex)中打开您的页面,并发布第一行代码(有时编辑器在第一个字节中放置错误的数据,我偶然发现过一次)

If this site is placed online, post it's url and I try to find a problem. 如果此网站在线放置,请发布其网址,然后我尝试查找问题。

Check response header of you server it must contains something like this: 检查服务器的响应头,它必须包含以下内容:

Key Value 核心价值

Content-Type text/html; 内容类型text / html; charset=utf-8 字符集= utf-8的

Response HTTP/1.1 200 OK 响应HTTP / 1.1 200 OK

if it's not then check you server settings or you code there must be place where Content-type header changes 如果不是,请检查您的服务器设置,或者您编写代码,必须在其中更改Content-type标头

EDIT: ok, encoding is right, as suggested in the comment you shoul check first bytes of you response, it seems like it starts with additional bytes (usually info about encoding) 编辑:好的,编码是正确的,如注释中所建议,您应该检查响应的第一个字节,似乎它以其他字节开头(通常是有关编码的信息)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM