Re: DOCTYPE



..., DW offers "Western European" as an option, and if I choose that then ISO-8859-1 is what actually gets inserted into the (mostly useless) meta-tag. So that makes 3 synonyms for the same charset.

Also, after thinking a bit, the fact that the output originates dynamically as php shouldn't matter, right? If I were to download my php page, save the source as *.html, and then publish that file as *.html, then the end result is the same - as far as DOCTYPE goes.

Not entirely. The best way to send the character set is _outside_ the document itself. It is a strange that you should parse the character set used out of the encoded document. What about utf-16? or utf-32? Could you parse those character sets as easily out of a documented that is written in it? Off course not. And if you can, there is no reason to do so anymore.

So character sets are sent in a header. PHP supports this in two ways:
- set the default document type and character set in your PHP.ini,
- send a header your self with the header() function;

Especially the first way can be tricky is you do not realize it. Your server may be sending "Content-type: text/html; charset=utf-8" in a header, while your code may contain "Content-type: text/html; charset=iso-8859-1" in a meta tag. Which of them is true?

So this was really an HTML question, independent of whether that the output originated as php.

As you saw above, not entirely. Plain static HTML files have no control over their headers.

Best regards.
.


Quantcast