【问题标题】:Error: The character encoding was not declared错误:未声明字符编码
【发布时间】:2015-10-08 01:03:02
【问题描述】:

我通过 W3 Total Cache 插件对 css 和 js 使用 minify。

在 W3C 验证器中我得到:

*错误:未声明字符编码。继续使用 windows-1252。

错误:更改字符编码 utf-8 并重新解析。

致命错误:此时更改编码将需要不可流式传输的行为。*

这是我在源代码中的内容:

我的 head.php 看起来像这样

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

<link rel="stylesheet" type="text/css" href="http://www.travelersuniverse.com/wp-content/cache/minify/000000/79a08/single.include.e8a63c.css" media="all" />

<script async type="text/javascript" src="http://www.travelersuniverse.com/wp-content/cache/minify/000000/79a08/default.include.b31316.js"></script>
</head>

出于某种原因,W3 Total Cache 在字符编码上方插入了缩小文件。 设置字符编码后如何放置它们? 谢谢!

【问题讨论】:

  • 你没有声明doctype吗?
  • 是的,文档类型已声明。

标签: html wordpress utf-8 character-encoding w3c-validation


【解决方案1】:

我知道这篇文章很旧,但我今天遇到了同样的问题,我一直在寻找答案,直到我自己找到了答案。所以如果它可以帮助某人......

尝试在w3c html validator 上验证我的JSHangman.html 页面时出现以下错误:

Error: The character encoding was not declared. Proceeding using windows-1252.

Error: A charset attribute on a meta element found after the first 1024 bytes.

At line 39, column 25

 charset="utf-8" />↩  </head>↩

Error: Changing character encoding utf-8 and reparsing.

From line 39, column 5; to line 39, column 28

itle>↩    <meta charset="utf-8" />↩  </h

Fatal Error: Changing encoding at this point would need non-streamable behavior.

At line 39, column 28

arset="utf-8" />↩  </head>↩  <

其实答案就在第二个错误行:

错误:在前 1024 个字节之后发现的元元素上的字符集属性。

我的 标记和 标记之间有一个很大的注释(大约 20 行),这就是问题所在。我的问题一删除就解决了。

【讨论】:

    猜你喜欢
    • 2015-12-05
    • 2011-02-22
    • 2012-11-09
    • 1970-01-01
    • 2015-02-20
    相关资源
    最近更新 更多