From: mitty Date: Sun, 10 Mar 2013 09:54:24 +0000 (+0000) Subject: * convert to FB_HTMLCREF if there are malformed characters X-Git-Url: http://lab.mitty.jp/git/?a=commitdiff_plain;h=a1128c4312a43317531d547bd3af1f2f56bbaeb6;p=lab.git * convert to FB_HTMLCREF if there are malformed characters git-svn-id: https://lab.mitty.jp/svn/lab/trunk@203 7d2118f6-f56c-43e7-95a2-4bb3031d96e7 --- diff --git a/misc/save.pl b/misc/save.pl index 6b673a8..5c5a1db 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,7 +32,13 @@ 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 + ); + print ": $filename\n"; } my $suffix = 1;