Forum Moderators: phranque

Message Too Old, No Replies

AddCharset not working for W3C validator?

         

JAB Creations

7:42 pm on Jul 29, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This is not being found in the header sent to the W3C validator regardless of the fact that they explicitly suggest this technique.

AddCharset iso-8859-1 .php

How do I check the header of a file?

Is this the correct syntax for the htaccess file?

Does this have to specifically be at the top of the file or can it be placed anywhere in general?

jdMorgan

10:38 pm on Jul 29, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The WebmasterWorld Server Headers Checker [webmasterworld.com] should help. It should be available in your WebmasterWorld control panel at the lower left end of the menu.

[added] AddCharset documentation [httpd.apache.org] (Note charset specifications are in all-uppercase letters in the examples, but I doubt it would matter). [/added]

Jim

encyclo

12:45 am on Jul 30, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I am aware of several cases where the W3C validator has problems with charsets defined in HTTP headers, possibly due to parsing errors caused by the validator code itself (nothing proven, though). So the bug is often with the validator, not the page. You could try the WDG validator as a comparison.

Having said all that, you could try a few variations. If your entire site uses the same charset, you can set ISO-8859-1 as the default for everything:

AddDefaultCharset ISO-8859-1

This adds the charset header to absolutely everything, though - including script, CSS and image files.

Your second option (and what I usually end up doing) is to declare the charset with PHP (as you are already using it):

<?php header('Content-Type: text/html; charset=ISO-8859-1');?>

Although this shouldn't make any difference at all, the W3C validator doesn't usually have a problem when the charset is declared this way.

JAB Creations

5:28 am on Jul 30, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I was actually trying to validate my frame files as html 4.X but decided since I was creating the frames in JS (in the head to add to that) I could use the xml/xhtml 1.1 with the normal encoding method I normally use anyway. The php header option would be the second way I'd go about it! Thanks to both of you!