1

We have a website (www.semanticdesigns.com) that delivers a default encoding of ISO-8859-1. The pages are written in, guess what, ASCII mostly with some ISO-8859-1 characters.

We have a few example directories where the pages under that directory are actually UTF-8-encoded with BOM. (http://www.semanticdesigns.com/Products/Formatters/JavaHTMLJunit/index.html) These display fine in IE8 and IE9, but FireFox gets confused and displays just the BOM characters

 " "

My reading of the HTML standard is that we need to add a meta tag to those pages:

 <meta http-equiv="content-type" content="text/html;charset=UTF-8"></meta>

These pages are generated automatically if it isn't obvious, so this is an easy change to make. But, I tried patching this by hand, but it doesn't seem to have an effect on FireFox.

How does the browser actually decide which encoding to use? The default one provided by the server? Or what's in the meta tag? Suggestions on how to solve this problem, without changing the site default?

2 Answers 2

1

The charset specified by web server in the HTTP header has priority.

There are a few solutions to your problems:

  • Tell web server to output different header for files in some directories (use AddCharset of AddDefaultCharset directives in the context)
  • Convert all into UTF-8 and use only this charset
  • Convert your UTF-8 encoded pages into iso-8859-1 using HTML entities (I don't know if there is a parameter in JavaDoc allow you to do it)
0

as far as I know the meta tag ( < meta > ) is totally ignored in firefox

the correct way to specify charset is sending the "Content-type" http-header, not the html meta tag (that anyway should reflect the same value of the http one)

the rule that actually firefox uses to set the display encoding is:

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

if you are using Apache, try ( http://httpd.apache.org/docs/2.0/mod/core.html#page-header )

AddDefaultCharset UTF-8

if you are using php you can do also,

header("Content-type: text/html;charset=UTF-8");

if you need a better overview about http protocol's headers, you can download https://addons.mozilla.org/it/firefox/addon/live-http-headers/ that is an useful tool that shows all infos contained in http requests and http responses

hope this helps! Feel free to correct my English.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.