使用http头指定字符编码iso-8859-1而不是utf-8的麻烦? [英] Trouble with http header specifying character encoding iso-8859-1 rather than utf-8?
问题描述
我最近设计了一个包含德语和荷兰语字符的网站,我希望该页面使用字符编码utf-8。
I have recently designed a website that contains German and Dutch characters and I would like the page to use character encoding utf-8.
我添加了xml声明:
<?xml version="1.0" encoding="UTF-8"?>
和元标记:
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
当我在线查看网站时,德语文本中的特殊字符无法正确显示。当我尝试使用w3c验证器验证页面时,我收到以下警告:
When I viewed the website on-line, the special characters found in the German text were not displaying correctly. When I tried validating the page with the w3c validator, I got the following warning:
HTTP标头中指定的字符编码(iso- 8859-1)与XML声明(utf-8)中的值不同。我将使用HTTP标头中的值(iso-8859-1)。
The character encoding specified in the HTTP header (iso-8859-1) is different from the value in the XML declaration (utf-8). I will use the value from the HTTP header (iso-8859-1).
这是服务器问题吗?只是我已将相同的文件上传到我的不同服务器,并使用utf-8正确显示页面。
Is this a server issue? It's just that I have uploaded the same files to a different server of mine and the pages display correctly there using utf-8.
有关我将如何进行的任何帮助或建议关于将页面编码为utf-8将非常感激。
Any help or advice regarding how I would go about getting the page to encode as utf-8 would be greatly appreciated.
我很难过!
感谢jason,我找到了一个名为mod_mime-defaults.conf的文件
Thanks to jason, I found a file named mod_mime-defaults.conf
此文件包含以下内容:
# AddDefaultCharset UTF-8
AddDefaultCharset ISO-8859-1
如果我在AddDefaultCharset UTF-8之前删除#,您认为这有用吗?或者在AddDefaultCharset ISO-8859-1之前添加一个#。
If I remove the # from before AddDefaultCharset UTF-8, do you think this will help? Or maybe add a # before AddDefaultCharset ISO-8859-1.
我试过编辑这个文件,但我认为我没有权限。嗯......?
I tried editing this file, but I don't think I have permission. Hmmm...?
推荐答案
这可能是服务器问题。
This could be a server issue.
如果您正在使用Apache,请检查通常位于* nix服务器上的/etc/httpd/conf/httpd.conf中的Apache配置文件,其值为 AddDefaultCharset
。
If you are using Apache check the Apache config file usually located here /etc/httpd/conf/httpd.conf on a *nix server, for the value of AddDefaultCharset
.
此设置指定所有服务内容的默认值。如果它被注释掉,这意味着它将依赖于浏览器或META设置来确定Charset。
This setting specifies the default for all content served. If it is commented out, that means it will rely on the browser's, or META settings to determine the Charset.
这篇关于使用http头指定字符编码iso-8859-1而不是utf-8的麻烦?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!