Re: More on entities and  - SOLVED

William McKee <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.petal
Message-ID <[email protected]>
Hi folks,

OK, I have a resolution regarding the forced setting of the Content-type
header. This behavior was occurring with a cgi script being run via
Apache::Registry. The script uses CGI::Application which sets the
Content-type to text/html. Because this is an A::Registry script, I have
the PerlSendHeaders declarative on.

The end result is that something was defaulting the charset to
ISO-8859-1 despite my Apache settings which suggest to do otherwise. A
quick "hello world" test shows that CGI.pm is doing this if no charset
is specified in the type argument to the header() function:


This script uses the AddDefaultCharset setting to set the header:

    #!/usr/bin/perl
    use strict;
    print "Content-type: text/html\n\nHello World!\n";


This one sets it to ISO-8859-1:

    #!/usr/bin/perl
    use strict;
    use CGI;
    my $q = new CGI;
    print $q->header( -type => 'text/html');
    print "Hello World!";

You'll see the header printed as:

    Content-Type: text/html; charset=ISO-8859-1

If I specify the charset in the call to header(), all is well.
Personally, I think this is a bit heavy-handed of CGI.pm to force the
content-type. I'm not convinced it is a bug but it's darn close!

The mystery still remains as to why Perl is outputting the content in
UTF-8 on the production server and ISO-8859-1 on my test server. At
least I know how to handle it and think that the general consensus on
the Petal list is to set the Encoding when using Petal via overriding
the process() function or via a subclass of Petal.


Thanks!
William

-- 
Knowmad Services Inc.
http://www.knowmad.com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.