[thelist] character encoding & validation

Duncan O'Neill dbaxo at ihug.co.nz
Fri Jul 26 16:30:01 CDT 2002


Andrew Clover wrote:
> Duncan O'Neill <dbaxo at ihug.co.nz> wrote:
>
>>The validator is complaining about the character-
>>encoding. The server is spitting it out by default as
>><meta http-equiv="Content-Type" content="text/html; charset=UTF-16">
>
>
> That's no good. Setting Content-Type through a meta http-equiv hack
> can only work if the browser can read the <meta> tag itself.

<snip>
</snip>

>  If you want to use UTF-16 as a
> web page encoding, you must specify that *before* the document begins,
> by using a real HTTP header instead of a meta hack. In ASP you can do this
> with:
>
>   <% Response.ContentType="text/html; charset=utf-16" %>
>
> before the page begins.

Thanks for your reply, Andrew. Clear and useful, as usual.

I *don't* want to use utf-16 as the character set. The *server*
(IIS5.0) is adding this tag. In my ASP page I have:

<%
...
Response.Write(objXML.transformNode(objXSL))
...
%>

I'm not declaring a character set, but
<meta http-equiv="Content-Type" content="text/html; charset=UTF-16">
is still appearing on the page.

>
> HOWEVER. The page whose URL you posted is not actually UTF-16 encoded;
> did you mean UTF-8? Any browser that attempts to follow your charset
> declaration will display complete gibberish.

I've since tried adding a response.ContentType as you suggest.
This works in as far as the page now validates. *But* the page
still has the *server-added* character set utf-16 declaration,
and the W3C validator is giving me a warning.

         *  Warning: Character Encoding mismatch!  The character
encoding specified in the HTTP header («iso-8859-1») is different from
the one specified in the META element («utf-16»). I will use
«iso-8859-1» for this validation. *

Two more questions;

1) Is this conflilct likely to cause any major snafus? My browsers
    are display it OK....
2) Do you know of a way to prevent the server automatically adding
    the <meta http-equiv> statement? Unlikely, since I don't have
    can't configure the server, but I thought I'd ask anyway.

tia,

--
=====================================================
Duncan O'Neill
"Smith The Reporter"
http://homepages.ihug.co.nz/~dbaxo/urban_legend.htm
=====================================================




More information about the thelist mailing list