Re: CGI and character encoding

Michael Schout <[email protected]>
Newsgroups gmane.comp.apache.mod-perl
Message-ID <[email protected]>
On 02/24/2011 03:31 PM, André Warnier wrote:
> Hi.
> 
> I wonder if someone here can give me a clue as to where to look...

If you have a fairly recent CGI.pm, it will decode utf-8 properly for
you (even avoiding double-decoding), but there are some caveats.  In
addition to what others have already said, If you are running under
mod_perl (which obviously you are), CGI.pm adds a cleanup handler (via
register_cleanup) which resets CGI.pm's global variables.  One of the
variables that gets reset is the PARAM_UTF8 variable (which the  -utf8
import controls).  Because of this, once the clenaup handler gets
called, UTF-8 decoding gets turned off.

You have to work around this by manually making sure $CGI::PARAM_UTF8 =
1 before calling CGI->new.

Regards,
Michael Schout
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.