#!/usr/bin/perl use strict; use warnings; use CGI qw(-oldstyle_urls); my $q = new CGI; print $q->url(-path_info => 1, -query => 1)."\n"; print $q->url(-path_info => 1, -query => 1)."\n" if (param_ie_convert($q)); use Jcode; sub param_ie_convert { my ($q) = @_; my $key = $q->param('key'); my $ie = $q->param('ie'); return unless defined $ie; $q->delete('ie'); return unless (defined $key and $key =~ /[\x80-\xff]/); return unless ($ie =~ /^(euc|sjis)$/); $q->param(-name=>'key', -value=>Jcode->new($key, $ie)->utf8); return 1; }
% a.pl 'key=%b9%e7%bd%c9&ie=euc&dummy=foo' http://localhost/./jcc.cgi?key=%B9%E7%BD%C9&ie=euc&dummy=foo http://localhost/./jcc.cgi?key=%E5%90%88%E5%AE%BF&dummy=foo