Mercurial > pub > Impl
diff Lib/IMPL/Web/Application.pm @ 130:06a34c197b05
Added support for utf-8 and old versions of CGI module
author | wizard |
---|---|
date | Wed, 16 Jun 2010 01:50:56 +0400 |
parents | e4f15cbc3f1a |
children | c5bc900eefd3 |
line wrap: on
line diff
--- a/Lib/IMPL/Web/Application.pm Tue Jun 15 20:12:58 2010 +0400 +++ b/Lib/IMPL/Web/Application.pm Wed Jun 16 01:50:56 2010 +0400 @@ -75,7 +75,7 @@ my ($this) = @_; return undef if $hasFetched; $hasFetched = 1; - my $query = CGI->new(); + my $query = CGIWrapper->new(); $query->charset($this->responseCharset); return $query; } @@ -94,6 +94,26 @@ } } +package CGIWrapper; +use base qw(CGI); + +use Encode; + +sub param { + my $this = shift; + + if (wantarray) { + my @result = $this->SUPER::param(@_); + + return map Encode::is_utf8($_) ? $_ : Encode::decode($this->charset,$_,Encode::LEAVE_SRC), @result; + } else { + my $result = $this->SUPER::param(@_); + + return Encode::is_utf8($result) ? $result : Encode::decode($this->charset,$result,Encode::LEAVE_SRC); + } + +} + 1; __END__