|
Posted by Jukka K. Korpela on 05/27/07 14:00
Scripsit fulio pen:
> There are foreign symbols in one of my html files, so the meta charset
> must be:
>
> <meta http-equiv="content-type" content="text/html; charset="gb2312" /
No, that's quite an incorrect idea. You should specify the character
encoding that has actually been used in the document. The encoding is
apparently UTF-16, so that's what you should specify. Actually, modern
browsers can infer UTF-16, so you could really mess things up if you used a
meta tag like the above. But you were lucky since your mistakes cancel each
out: you have a misplaced quotation mark, so that the meta tag has no
effect; the content attribute has the value
"text/html; charset="
and then gb2312 is taken as another attribute, and ignored because there is
no such attribute.
(By the way, a markup validator would have told all this, though somewhat
less clearly.)
("Foreign symbols"? Referring to Chinese characters as "foreign" in a
worldwide context is odd, since they are native characters to about one
billion people.)
> But either online or off, the external css works well only when the
> file is opened with the IE browser. When it opened with FF, the
> external css doesn't work at all. No markup takes effect.
That's because FF has more adequate error processing. Remmber the extra
quotation mark? It also implies that the last quotation mark in
<meta http-equiv="content-type" content="text/html; charset="gb2312" /
actually starts a quoted string. This means that processing of quoted
strings gets off the phase and very wild, and the <link> element is not
really processed at all.
The immediate fix would thus be either to remove the meta tag or change it
to
<meta http-equiv="content-type" content="text/html; charset=utf-16" />
More advice:
1) Drop XHTML 1.0. You're not even using it formally correctly. Stick to
HTML 4.01, consistently. Use either XHTML or HTML 4.01; don't mix them in
the same file (you now even use both syntaxes in meta tags).
2) Switch to UTF-8, which is much better supported than UTF-16, especially
in search engines. This means changing your authoring program to change the
actual encoding _and_ declaring UTF-8 encoding in an HTTP header and/or a
meta tag.
--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/
Navigation:
[Reply to this message]
|