in reply to Re: CGI::Application - Which is the proper way of handling and outputting utf8
in thread CGI::Application - Which is the proper way of handling and outputting utf8
package CGI::as_utf8; # add UTF-8 decode capability to CGI.pm BEGIN { use strict; use warnings; use CGI 3.47; # earlier versions have a UTF-8 double-decoding bug { no warnings 'redefine'; my $param_org = \&CGI::param; my $might_decode = sub { my $p = shift; # make sure upload() filehandles are not modified return $p if !$p || ( ref $p && fileno($p) ); utf8::decode($p); # may fail, but only logs an error $p }; *CGI::param = sub { # setting a param goes through the original interface goto &$param_org if scalar @_ != 2; my $q = $_[0]; # assume object calls always my $p = $_[1]; return wantarray ? map { $might_decode->($_) } $q->$param_org($p) : $might_decode->( $q->$param_org($p) ); } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: CGI::Application - Which is the proper way of handling and outputting utf8
by ikegami (Patriarch) on Mar 11, 2010 at 02:32 UTC | |
by Anonymous Monk on Dec 14, 2010 at 10:01 UTC | |
by davebaker (Pilgrim) on Oct 29, 2020 at 20:52 UTC | |
by Anonymous Monk on Oct 30, 2020 at 00:12 UTC | |
by davebaker (Pilgrim) on Oct 30, 2020 at 15:26 UTC | |
by ikegami (Patriarch) on Dec 15, 2010 at 23:52 UTC |