どんな文字列でもエスケープ、アンエスケープすることは出来る。この出力はもしかするとユーザの思い通りに動いていないかもしれない。本来URIエスケープせねばいけない部分を切り出してエスケープしなければいけない。
$ perl -l -MURI::Escape -e 'print URI::Escape::uri_escape("http://www.google.com/search?q=perl");' http%3A%2F%2Fwww.google.com%2Fsearch%3Fq%3Dperl $ perl -l -MURI::Escape -e 'print URI::Escape::uri_unescape("http://www.google.com/search?q=perl+1%E8%A1%8C&num=100");' http://www.google.com/search?q=perl+1行&num=100
URIエスケープするべき部分を切り出して。
use URI::Escape; my $unescaped = "日本語"; my $escaped = ""; $escaped = uri_escape( $unescaped ); #URLエンコード済み文字列へのエンコード $unescaped = uri_unescape( $escaped ); #URLエンコード済み文字列のデコード