Subject: | -charset and -encoding are out of sync |
Currently it is possible to produce output like this:
-------------
use CGI;
my $q = CGI->new;
$q->charset("utf-8");
print $q->header, $q->start_html;
--------------
prints
Content-Type: text/html; charset=utf-8
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
where the charset specified in the HTTP header and in the http-eqiv meta
differ.
As bug 16750 (no charset output in the http header at all with
Content-Type not matching /^text/) will be fixed in 3.16, xhtml output
could soon even look like this:
------
use CGI;
my $q = CGI->new;
$q->charset("utf-8");
print $q->header(-type => "application/xhtml+xml"),
$q->start_html(-declare_xml => 1);
-------
prints
Content-Type: application/xhtml+xml; charset=utf-8
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">
<head>
<title>Untitled Document</title>
</head>
<body>
The http charset and encoding should be synchronized, and, if not for
what reasons ever, the behavior described above should at least be
specifically addressed in the documentation like
(to be inserted at line 4991 in the source)
Please note that setting a specific encoding in start_html() does not
automatically adjust the charset setting in the Content-Type HTTP header.
(to be inserted at line 5460 in the source)
Please note that setting a specific charset with charset() or as a
parameter in a header() call does not autmatically adjust the encoding
declarations as produced by start_html().
Regards
Bodo