Html 字符集 UTF-8 不起作用(被这些 ?-marks 卡住了)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5533504/
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 07:46:27  来源:igfitidea点击:

Charset UTF-8 doesn't work (stuck with these ?-marks)

htmlcssunicode

提问by Ingtór Ingólfsson

I have a Unicode problem... I′ve done this before but for now, I cannot understand why the Icelandic letters don′t show up - I have those question marks again

我有一个 Unicode 问题......我以前做过这个,但现在,我不明白为什么冰岛字母不显示 - 我又遇到了那些问号

Here is the url (very plain and short html5) http://nicejob.is/new/

这是网址(非常简单和简短的 html5) http://nicejob.is/new/

Everything I Google says: use the <meta charset="utf-8">as I do.

我谷歌所说的一切:<meta charset="utf-8">像我一样使用。

Any suggestions?

有什么建议?

回答by Czechnology

Your page is already viewedas UTF-8. But your source code is not savedas UTF-8.

您的页面已视为 UTF-8。但是您的源代码没有保存为 UTF-8。

Please change the encoding of your source code file to UTF-8.

请将源代码文件的编码更改为 UTF-8。

回答by Larry Cinnabar

Not all browsers support HTML5-way tags yet

并非所有浏览器都支持 HTML5-way 标签

hereyou can see table of compability

在这里你可以看到兼容性表

Try this instead:

试试这个:

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

回答by Roger Willcocks

I can see a couple of issues.

我可以看到几个问题。

  1. The META should look like this:

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

  2. The <html>specified lang="en"which might be prone to confusing some browsers.

  1. META 应如下所示:

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

  2. 可能容易混淆某些浏览器的<html>指定lang="en"

回答by Jonathan Leffler

When I view the HTML from the browser, the question marks are encoded as 0xEF 0xBF 0xBD, which is the UTF-8 encoding for the byte order mark or BOM, aka U+FEFF. So, for whatever reason, the HTML is not transmitted as sensible UTF-8 (though it does seem to be valid UTF-8).

当我从浏览器查看 HTML 时,问号被编码为 0xEF 0xBF 0xBD,这是字节顺序标记或 BOM(即 U+FEFF)的 UTF-8 编码。因此,无论出于何种原因,HTML 都不会作为合理的 UTF-8 传输(尽管它似乎确实是有效的 UTF-8)。

回答by mohammed balhadadd

What you have to do is to save the file with utf-8 encoding by using Notepad (the attached one with Windows).

您需要做的是使用记事本(Windows 附带的)以 utf-8 编码保存文件。

Steps:

脚步:

  • Save as ..

  • In the below options ... you will find encoding option choose UTF-8 ...

  • And save the file ...

  • Then add the line <meta charset="UTF-8" />inside your file ...

  • 另存为 ..

  • 在下面的选项中......你会发现编码选项选择UTF-8 ...

  • 并保存文件...

  • 然后<meta charset="UTF-8" />在您的文件中添加该行...

And it will work.

它会起作用。

回答by Milorad Simic

Probably you are using some text editor like notepad++, and you didn't set up encoding to UTF-8 in that text editor.

可能您正在使用诸如记事本++之类的文本编辑器,并且您没有在该文本编辑器中将编码设置为 UTF-8