简体   繁体   English

HTML UTF-8编码

[英]HTML UTF-8 encoding

When I save in an editor (Notepad++) an HTML file as "utf-8" encoded the meta tag charset (=ISO-8859-2) seems to be ignored by browser (charset is always set to "utf-8", not matter which encoding i have set in meta tag) 当我在编辑器(Notepad ++)中保存一个HTML文件作为“utf-8”编码时,meta标签charset(= ISO-8859-2)似乎被浏览器忽略(charset始终设置为“utf-8”,而不是我在元标记中设置的编码问题)

What's more interesting when i save this doc as "ANSI" encoded file changing tag charset works... 当我将此文档保存为“ANSI”编码文件更改标记字符集时,更有趣的是......

Can You please explain me such a behaviour? 你能解释一下这样的行为吗?

You can use META. 您可以使用META。 Like this: 像这样:

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

"UTF-8" in Notepad++ really means "UTF-8 with BOM ". Notepad ++中的“UTF-8”实际上意味着“带BOM的 UTF-8”。 The leading BOM very likely triggers UTF-8, regardless of what anything else is saying, since no other document should start with that particular byte sequence. 领先的BOM非常可能触发UTF-8,无论其他什么说法,因为没有其他文档应该从该特定字节序列开始。 Try saving as "UTF-8 without BOM" to see the difference. 尝试保存为“无BOM的UTF-8”以查看差异。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM