问题描述
我在Ubuntu上用gvim创建了一个html文件。当我使用Safari或Google Chrome在windows上打开这个文件时,它没有正确显示éë。当我使用vim:set encoding检查我的Windows框上的编码?它返回latin1,在Unbuntu上返回utf-8。任何人都可以解释为什么会发生这种情况,以及如何解决这个问题?
您需要考虑Chrome应该如何知道要使用的编码方式。
通常,这是使用HTTP标头或< meta http-equiv =Content-Typecontent =text / html; charset = iso-8859-1>
没有控制标题。
我想象你的情况你没有。如果您还没有使用例如魔术评论标题如#vim:set fileencoding =< encoding name>
,则编辑器报告的编码将取决于系统默认值。在任何情况下,您的浏览器将不知道如何解释。
I created a html file with gvim on Ubuntu. When I open this file on windows with Safari or Google Chrome it's not showing é ë correctly. When I check the encoding on my windows box with vim :set encoding? it returns latin1 and on Unbuntu this returns utf-8.
Could anybody explain why this is happening and how I can fix this?
You need to consider how Chrome is supposed to know which encoding to use.
Usually, this is with an HTTP header or a <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
if you don't have control over the headers.
I imagine in your case you have neither. If you've not set the source code encoding using e.g. magic comment headers like # vim: set fileencoding=<encoding name>
, then the encoding your editor reports will depend on the system defaults. And in any case, you browser won't know how to interpret that.
这篇关于Webkit:编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!