开发者

Webkit: Encoding

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 Ubuntu this returns utf-8.

Could anybody explain why th开发者_Python百科is is happening and how I can fix this?


  1. Make sure that you're actually saving the file as UTF-8.
  2. Is this in your <head>?

    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    
  3. How are you serving the file? If you're using an actual HTTP server (rather than just opening a local .html file) make sure to serve it with the right headers:

    Content-Type: text/html; charset=UTF-8
    

If none of these help, could you show us the actual file (even a Dropbox download link would help)?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜