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

#####  CGI::Application community mailing list  ################
##                                                            ##
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp    ##
##                                                            ##
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:          http://cgiapp.erlbaum.net/                 ##
##                                                            ##
################################################################

Reply via email to