X-Git-Url: http://lab.mitty.jp/git/?a=blobdiff_plain;f=misc%2Fsave.pl;h=77b6fb131a9f4acb671285ddae287baa467f7ef6;hb=5ab4cdffb02cff55b646f1905700b8a2ec0c2494;hp=6b673a8de1dcff584bed710cfebea7e553c21d16;hpb=a74d46aaffc01258959a744d35aaad30d58f425d;p=lab.git diff --git a/misc/save.pl b/misc/save.pl index 6b673a8..77b6fb1 100755 --- a/misc/save.pl +++ b/misc/save.pl @@ -13,7 +13,6 @@ my $target = shift @ARGV || die "$0: URL or file-of-url-list [coding]\n"; my $coding = shift @ARGV || 'utf8'; my $ua = LWP::UserAgent->new; -my $enc = find_encoding($coding); my @URLs; if ($target !~ /^http/ && -f $target) { @@ -33,8 +32,22 @@ foreach my $url (@URLs) { my $filename = $res->filename; my $decoder = Encode::Guess->guess($filename); if (ref($decoder)) { - $filename = $enc->encode($decoder->decode($filename)); + print $decoder->name; + $filename = encode( + $coding, + $decoder->decode($filename), + Encode::FB_HTMLCREF + ); } + else { + print "utf8?"; + $filename = encode( + $coding, + decode("utf8", $filename), + Encode::FB_HTMLCREF + ); + } + print ": $filename\n"; my $suffix = 1; my $savename = $filename;