Re: character encoding in CGI.pm
From: Shawn Corey (shawn.corey_at_sympatico.ca)
Date: 11/25/04
- Next message: Matt Garrish: "Re: redirect question"
- Previous message: KKramsch: "Re: *HELP* please: how to dupe STDIN in an IO::Scalar?"
- In reply to: David Lee Lambert: "character encoding in CGI.pm"
- Next in thread: Alan J. Flavell: "Re: character encoding in CGI.pm"
- Reply: Alan J. Flavell: "Re: character encoding in CGI.pm"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 24 Nov 2004 21:10:33 -0500
David Lee Lambert wrote:
> I noticed that, without setting any options, CGI.pm output of a
> simple page starts as follows:
>
> Content-Type: text/html; charset=ISO-8859-1
>
> <?xml version="1.0" encoding="utf-8"?>
>
>
> Now, is the webpage in ISO-8859-1, utf8, or some other encoding? Or
> is XML defined such that this is a perfectly valid situation? If I
> send a string containing Unicode characters (with \x{}), IE 6 detects
> the page as Latin-1 and doesn't show those characters properly; if I
> manually tell it that the encoding is UTF-8, it displays the
> characters properly.
>
> This is using perl 5.6.1; I'm not sure what verion of CGI.p I have.
>
> --
> DLL
The web page is both. The ISO-8859-1 encoding is used for the HTTP
transfer. All bytes, including the web page, while be interpreted as
ISO-8859-1 encoded until handed off to the display engine in the
browser. Then it will be interpreted as UTF-8. This normally does not
mean much since the bytes after the blank line are usually not processed
by the HTTP decoding code; they are simply passed to the next part.
If you are using Perl 5.6, add 'use utf8;' to the code. For any Perl,
you can add:
print handler( -charset => 'UTF-8' );
for the Content-Type handler.
See perldoc CGI for details.
--- Shawn
- Next message: Matt Garrish: "Re: redirect question"
- Previous message: KKramsch: "Re: *HELP* please: how to dupe STDIN in an IO::Scalar?"
- In reply to: David Lee Lambert: "character encoding in CGI.pm"
- Next in thread: Alan J. Flavell: "Re: character encoding in CGI.pm"
- Reply: Alan J. Flavell: "Re: character encoding in CGI.pm"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|