[cgiapp] utf8 form processing
Mike Tonks
fluffymike at googlemail.com
Wed Oct 15 11:03:10 EDT 2008
Hi All,
I recently encountered the dreaded utf8 funny characters, again. This
time on the input data coming from form entry fields.
It's CGI.pm that actually does the processing, and needs to read the
stream as utf8. There is a flag for this, but I couldn't get that to
work, so as a temporary measure I read all the parameters and pass
them through decode_utf8. Does anyone have a better method?
sub cgiapp_get_query {
my $c = shift;
# Include CGI.pm and related modules
require CGI;
# This doesn't work, not sure why
#use CGI qw(-utf8);
# Get the query object
my $q = CGI->new();
foreach my $key (keys %{$q->Vars}) {
#warn "q - $key: " . $q->param($key) . "[" .
decode_utf8($q->param($key)) . "]";
$q->param($key, decode_utf8($q->param($key)));
}
return $q;
}
Regards,
mike
More information about the cgiapp
mailing list