From: mitty Date: Thu, 24 Jan 2013 15:11:26 +0000 (+0000) Subject: * fix: use Encode to correctly handle utf9 file or directory name X-Git-Url: http://lab.mitty.jp/git/?p=lab.git;a=commitdiff_plain;h=e4e7407c6608e107411d338d4820da5109a51f66 * fix: use Encode to correctly handle utf9 file or directory name * NFKC replaces much more than expected git-svn-id: https://lab.mitty.jp/svn/lab/trunk@192 7d2118f6-f56c-43e7-95a2-4bb3031d96e7 --- diff --git a/misc/findcombinable.pl b/misc/findcombinable.pl index 3e5f51d..7b9d629 100755 --- a/misc/findcombinable.pl +++ b/misc/findcombinable.pl @@ -4,11 +4,17 @@ use strict; use warnings; use utf8; +use Encode; use Unicode::Normalize qw(NFC NFKC); +binmode STDOUT => 'encoding(utf8)'; +binmode STDERR => 'encoding(utf8)'; my $top = shift @ARGV || exit; if (! -d $top) { exit; } +my $utf8 = find_encoding("utf8"); +$top = $utf8->decode($top); + checkdir($top); sub match { @@ -17,9 +23,6 @@ sub match { if ($str ne NFC($str)) { return 1; } - if ($str ne NFKC($str)) { - return 1; - } return ''; } @@ -35,6 +38,7 @@ sub checkdir { my @dirs; while (my $entry = shift @entries) { next if ($entry =~ /^\.+$/); + $entry = $utf8->decode($entry); if (match($entry)) { print "'$target/$entry' can be composed\n"; next;