in reply to Header, start_html and encodings

Presuming you're talking about the header and start_html methods that are part of CGI...

header specifies the character encoding in the HTTP content-type header (the part of an HTTP server response that the user doesn't see when you do a view-source):
Content-type: text/html; charset=UTF-8
start_html specifies the character encoding as part of a <meta> tag within the body of the HTML document:
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
Assuming a browser is standards compliant, both methods of specifying the content encoding would accomplish the same thing.

--Brian

Replies are listed 'Best First'.
Re^2: Header, start_html and encodings
by dorward (Curate) on May 25, 2006 at 08:26 UTC

    The spec is a bit fuzzy when it comes to HTTP-EQUIV. While it does say:

    The META element may be used to specify the default information for a document

    and

    The following example specifies the character encoding for a document as being ISO-8859-5

    <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-5">

    It also says:

    http-equiv = name CI

    This attribute may be used in place of the name attribute. HTTP servers use this attribute to gather information for HTTP response message headers.

    Although the only server I'm aware of which actually does this is Russian Apache (you have to have a way of specifing http headers for all media types, so why bother having an HTML specific one?).

    I can't find anywhere in the spec that says that user agents that are not servers should pay any attention to HTTP-EQIV whatsoever.

    There is also the issue that it is rather difficult to read a document if the character encoding is unknown. If the only way to find out the character encoding is to read the document, then you have a problem.

    Real HTTP headers are the way to go, and I'm not aware of any user agent that has a problem with them.