如何更改“实际编码”我的HTML文件? [英] How do I change the "actual encoding" of my HTML document?

查看:135
本文介绍了如何更改“实际编码”我的HTML文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


编码ascii不是首选的名称字符
编码正在使用中。首选的名字是us-ascii。 (Charmod C024)✉
第5行,第70列:内部编码声明utf-8不同意
文档的实际编码(us-ascii)。



 < meta http-equiv =content-typecontent =text / html; charset = utf-8> 

显然,即使我在我的UTF-8中指定了UTF-8,元标记。



我怎样才能实际使用UTF-8?这甚至意味着什么?

解决方案

验证器的HTML5模式将编码声明之间的不匹配视为错误。在消息中,内部编码声明是指 meta 标记,例如< meta charset = utf-8> 和实际编码(误导性)是指HTTP头文件中的编码声明。

根据当前的HTML规范(HTML5仅仅是一个草稿),错配不是一个错误,并且HTTP标头赢。



如果您的文档仅包含Ascii字符,则不存在实际问题。 Ascii编码的数据也是UTF-8编码,因为在UTF-8中,任何Ascii字符都表示为单个字节,与Ascii中的值相同。



这取决于服务器端使用的软件是否以及如何更改HTTP标头。如果他们现在指定charset = ascii,就像它看起来那样,除非在验证中,否则它不是一个真正的问题,前提是您只使用Ascii字符。但它有些古怪而且过时。尝试将编码信息更改为charset = utf-8。您不需要更改实际的编码,但如果您以后添加了非ASCII字符,请确保通过在创作程序中选择合适的命令或选项将该文件保存为UTF-8编码。


I ran my web page through the W3C HTML validator and received this error.

The encoding ascii is not the preferred name of the character encoding in use. The preferred name is us-ascii. (Charmod C024) ✉ Line 5, Column 70: Internal encoding declaration utf-8 disagrees with the actual encoding of the document (us-ascii).

<meta http-equiv="content-type" content="text/html;charset=utf-8">

Apparently, I am not "actually" using UTF-8 even though I specified UTF-8 in my meta tag.

How do I, well, "actually" use UTF-8? What does that even mean?

解决方案

The HTML5 mode of the validator treats a mismatch between encoding declarations as an error. In the message, "internal encoding declaration" refers to a meta tag such as <meta charset=utf-8>, and "actual encoding" (misleadingly) refers to encoding declaration in HTTP headers.

According to current HTML specifications (HTML5 is just a draft), the mismatch is not an error, and the HTTP headers win.

There is no real problem if your document only contains Ascii characters. Ascii-encoded data is trivially UTF-8 encoded too, because in UTF-8, any Ascii character is represented as a single byte, with the same value as in Ascii.

It depends on the software used server-side whether and how you can change the HTTP headers. If they now specify charset=ascii, as it seems, it is not a real problem except in validation, provided that you keep using Ascii characters only. But it is somewhat odd and outdated. Try to have the encoding information there changed to charset=utf-8. You need not change the actual encoding, but if you later add non-Ascii characters, make sure you save the file as UTF-8 encoded by selecting a suitable command or option in the authoring program.

这篇关于如何更改“实际编码”我的HTML文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆