No, it's not possible from within the HTML. The servers response header take precedence over the document's meta-tag. As it's specified in 5.2.2 Specifying the character encoding - HTML 4.01 Specification :
To sum up, conforming user agents must observe the following priorities when determining a document's character encoding (from highest priority to lowest):
- An HTTP "charset" parameter in a "Content-Type" field.
- A META declaration with "http-equiv" set to "Content-Type" and a value set for "charset".
- The charset attribute set on an element that designates an external resource.
So this requires configuration on the server-side. However as the chapter continues:
User agents may provide a mechanism that allows users to override incorrect "charset" information. However, if a user agent offers such a mechanism, it should only offer it for browsing and not for editing, to avoid the creation of Web pages marked with an incorrect "charset" parameter.
In my case the the server's Content-Type header contains the right mime-type but the wrong charset.
As it turned out, my Apache httpd configuration had set the
AddDefaultCharset turned on which was adding the
; charset=ISO-8859-1 part. Placing into the websites root directory
.htaccess the following line:
the charset information was removed:
$ curl -I http://example.com/file.html
HTTP/1.1 200 OK
Date: Fri, 19 Oct 2012 15:07:52 GMT
(see last line, no
; charset=... part). This in combination with the html meta-tag triggers the said browser heuristics to take over the charset from the meta tag. The website is properly decoded.
- Google Chrome v. 22.0.1229.94
- Firefox v. 16.0.1
- Lynx Version 2.8.7rel.1 (05 Jul 2009)
These three browsers had problems with the original configuration and work now (all on Fedora 17).
- Opera 12.02
- Internet Explorer 6 (Win XP SP3)
Didn't have the problem in the first place. Both were preferring UTF-8 from the meta-tag over the ISO-8859-1 setting from the server.
Does not support UTF-8 so is always choosing Western(Latin1) regardless of the server setting and the meta-tag.