为什么钻石上有问号?出现在我的 HTML 中?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15276191/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 06:13:20  来源:igfitidea点击:

Why does a diamond with a questionmark in it ? appear in my HTML?

html

提问by user1032531

I have an unorder list, and ? often (but not always!) appears where I have have two spaces between characters. What is causing this, and how do I prevent it?

我有一个无序列表,还有 ? 经常(但不总是!)出现在字符之间有两个空格的地方。这是什么原因造成的,我该如何预防?

采纳答案by Pekka

This specific character ? is usually the sign of an invalid (non-UTF-8) character showing up in an output (like a page) that has been declared to be UTF-8. It happens often when

这个具体的性格?通常是在已声明为 UTF-8 的输出(如页面)中显示的无效(非 UTF-8)字符的标志。它经常发生在

  • a database connection is not UTF-8 encoded (even if the tables are)

  • a HTML or script source file is stored in the wrong encoding (e.g. Windows-1252 instead of UTF-8) - make sure it's saved as a UTF-8 file. The setting is often in the "Save as..." dialog.

  • an online source (like a widget or a RSS feed) is fetched that isn't serving UTF-8

  • 数据库连接不是 UTF-8 编码的(即使表是)

  • HTML 或脚本源文件以错误的编码存储(例如 Windows-1252 而不是 UTF-8) - 确保将其保存为 UTF-8 文件。该设置通常位于“另存为...”对话框中。

  • 获取了不提供 UTF-8 的在线资源(如小部件或 RSS 提要)

回答by topcat3

It's a character-set issue. Get a tool that inspects the response headers of the server (like the Firebug extension if you're using Mozilla Firefox) to see what character set the server response is sending with the content. If the server's character-set and the HTML character set of the actual content don't match up, you will see some strange looking characters like those little black diamond squares.

这是一个字符集问题。获取检查服务器响应标头的工具(如使用 Mozilla Firefox 的 Firebug 扩展),以查看服务器响应随内容发送的字符集。如果服务器的字符集和实际内容的 HTML 字符集不匹配,你会看到一些奇怪的字符,比如那些小黑菱形方块。

回答by pradip

I had the same issue ....

我遇到过同样的问题 ....

You can fix it by adding the following line in your template !

您可以通过在模板中添加以下行来修复它!

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

For more details :

更多细节 :

Read this - http://blog.salientdigital.com/2009/06/06/special-characters-showing-up-as-a-question-mark-inside-of-a-black-diamond/comment-page-1/#comments

阅读此内容 - http://blog.salientdigital.com/2009/06/06/special-characters-showing-up-as-a-question-mark-inside-of-a-black-diamond/comment-page-1 /#注释

回答by Nathanael Istre

I had the same issue when getting an HTML output from an XSLT. Along with Pradip's solution I was also able to resolve the issue using UTF-32.

从 XSLT 获取 HTML 输出时,我遇到了同样的问题。除了 Pradip 的解决方案,我还能够使用 UTF-32 解决该问题。

<meta http-equiv="Content-Type" content="text/html; charset=UTF-32" />