Firefox – Why does Firefox disable the ‘Character encoding’ menu for some sites


For some websites I noticed the Firefox's 'View/character encoding' menu is disabled, why?

Is it possible to enable it?

Best Answer

It's due to the fix for Bug 234628, Disable View>Character Coding menu when it won't have effect / is unnecessary (e.g. XML).

Specifically, if you look at comment #63:

As for the case where there is a UTF-8 BOM, it makes sense to let the BOM take precedence over the menu

The BOM is used to identify the order of bytes in a Unicode-encoded document.

The reasons given can be summarised as:

  • Gecko (Firefox's rendering engine) does not support any other encoding that would render a BOM as a valid HTML start (<html or <!DOCTYPE etc.).

  • Other major browsers (IE6+, WebKit-based [Chrome, etc.]) do the same thing. For example, if you try to change the encoding on Chrome it just resets back to UTF-8.

  • Doing otherwise could potentially mess up form input.

The example page you provided starts with the three UTF-8 BOM bytes. You can see this if you save the page and open the HTML file in a hex editor. The BOM positively identifies it as a UTF-8 document, and opening it in any other encoding would not yield a correct HTML page.

Screenshot of hex editor showing BOM

You can see the 0xEF 0xBB 0xBF BOM on the left, as described on Wikipedia. On the right, it shows what it looks like when rendered as ANSI/CP1252.

If you really want to, you can save the file, strip off the offending BOM and open the file. Or you can set up a proxy (Fiddler2 is good for this) that will intercept and modify the files before they get to your browser. However, these aren't really good solutions, and are likely to just create further problems. The best thing to do, if you have encoding issues, is to contact the website maintainer. We should all be moving to Unicode where possible anyway, not using the older and more limited encoding standards.