Search code examples
htmlunicodeencodingwebkit

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 this is happening and how I can fix this?


Solution

  • 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.