Html 为什么像撇号和连字符这样的符号在我的网站上被替换为黑色菱形?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4086717/
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
Why do symbols like apostrophes and hyphens get replaced with black diamonds on my website?
提问by Ortund
A website I've made has a few problems... On one of the pages, wherever there's an apostrophe ('
) or a dash (-
), the symbol gets replaced with a weird black diamond with a question mark in the center of it
我创建的网站有一些问题......在其中一个页面上,只要有撇号 ( '
) 或破折号 ( -
),符号就会被替换为一个奇怪的黑色菱形,中间有一个问号
Here's what I mean
这就是我的意思
It seems this is happening all over the site wherever these symbols appear. I've never seen this before, can anyone explain it to me?
无论这些符号出现在哪里,这似乎都发生在整个网站上。我以前从未见过这个,谁能给我解释一下?
Suggestions on how to fix it would also be greatly appreciated.
关于如何修复它的建议也将不胜感激。
See http://test.rfinvestments.co.za/index.php?c=teamfor a clear look at the problem.
请参阅http://test.rfinvestments.co.za/index.php?c=team以清楚地了解问题。
回答by joni
It's an encoding problem. You have to set the correct encoding in the HTML head via meta tag:
是编码问题。您必须通过元标记在 HTML 头中设置正确的编码:
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
Replace "ISO-8859-1" with whatever your encoding is (e.g. 'UTF-8'). You must find out what encoding your HTML files are. If you're on an Unix system, just type file file.html
and it should show you the encoding. If this is not possible, you should be able to find out somewhere what encoding your editor produces.
将“ISO-8859-1”替换为您的编码(例如“UTF-8”)。您必须找出 HTML 文件的编码方式。如果您使用的是 Unix 系统,只需键入file file.html
,它就会向您显示编码。如果这是不可能的,您应该能够在某处找到您的编辑器产生的编码。
回答by Karlgoldstraw
You need to change your text to 'Plain text' before pasting into the HTML document. This looks like an error I've had before by pasting straight from MS word.
在粘贴到 HTML 文档之前,您需要将文本更改为“纯文本”。这看起来像是我之前直接从 MS word 粘贴的错误。
MS word and other rich text editors often place hidden or invalid chars into your code. Try using —
for your dashes, or ’
for apostrophes (etc), to eliminate the need for relying on your char encoding.
MS Word 和其他富文本编辑器经常将隐藏或无效的字符放入您的代码中。尝试使用—
您的破折号或’
撇号(等),以消除依赖于您的字符编码的需要。
回答by Ajay2707
I have the same issue in my asp.net web application. I solved by this link
我在我的 asp.net Web 应用程序中遇到了同样的问题。我通过这个链接解决了
I just replace ' with ’
text like below and my site in browser show apostrophe without rectangle around as in question ask.
我只是用’
下面的文字替换 ' ,我的网站在浏览器中显示撇号,周围没有矩形,如问题所问。
Original text in html page
Click the Edit button to change a field's label, width and type-ahead options
Replace text in html page
Click the Edit button to change a field’s label, width and type-ahead options
回答by user6784003
If you are editing HTML in Notepad you should use "Save As" and alter the default "Encoding:" selection at the botom of the dialog to UTF-8. you should also include-
如果您在记事本中编辑 HTML,您应该使用“另存为”并将对话框底部的默认“编码:”选择更改为 UTF-8。你还应该包括——
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
This un-ambiguously sets the correct character set and informs the browser.
这明确地设置了正确的字符集并通知浏览器。
回答by Leonid Barrington
Look at your actual html code and check that the weird symbols are not originating there. This issue came up when I started coding in Notepad++ halfway after coding in Notepad. It seems to me that the older version of Notepad I was using may have used different encoding to Notepad's++ UTF-8 encoding. After I transferred my code from Notepad to Notepad++, the apostrophes got replaced with weird symbols, so I simply had to remove the symbols from my Notepad++ code.
查看您的实际 html 代码并检查奇怪的符号是否来自那里。当我在记事本中编码后开始在 Notepad++ 中编码时出现了这个问题。在我看来,我使用的旧版记事本可能使用了与记事本 ++ UTF-8 编码不同的编码。在我将代码从记事本转移到记事本++后,撇号被奇怪的符号替换了,所以我只需要从记事本++代码中删除这些符号。
回答by Testilla
I experienced the same problem when I copied a text that has an apostrophe from a Word document to my HTML code.
当我将带有撇号的文本从 Word 文档复制到我的 HTML 代码时,我遇到了同样的问题。
To resolve the issue, all I did was deleted the particular word in my HTML and typed it directly, including the apostrophe. This action nullified the original copy and paste acton and displayed the newly typed apostrophe correctly
为了解决这个问题,我所做的只是删除了 HTML 中的特定单词并直接输入,包括撇号。此操作使原始复制和粘贴操作无效并正确显示新键入的撇号
回答by Adrian Fox
What I really don't understand with this kind of problem is that the html page I ran as a local file displayed perfectly in Chromium browser, but as soon as I uploaded it to my website, it produced this error.
对于此类问题,我真正不明白的是,我作为本地文件运行的 html 页面在 Chromium 浏览器中完美显示,但是一旦我将其上传到我的网站,它就会产生此错误。
Even stranger, it displayed perfectly in the Vivaldi browser whether displayed from the local or remote file.
更奇怪的是,无论是从本地文件还是远程文件显示,它都能在 Vivaldi 浏览器中完美显示。
Is this something to do with the way Chromium reads the character set? But why only with a remote file?
这与 Chromium 读取字符集的方式有关吗?但为什么只使用远程文件?
I fixed the problem by retyping the text in a simple text editor and making sure the single quote mark was the one I used.
我通过在一个简单的文本编辑器中重新输入文本并确保单引号是我使用的那个来解决这个问题。