Last change
on this file since 190 was
190,
checked in by mitty, 11 years ago
|
- replace Unicode::Japanese with Encode
|
-
Property svn:executable set to
*
|
File size:
1004 bytes
|
Rev | Line | |
---|
[187] | 1 | #! /usr/bin/perl -w |
---|
| 2 | |
---|
| 3 | use strict; |
---|
| 4 | use warnings; |
---|
| 5 | use utf8; |
---|
| 6 | use encoding 'utf-8'; |
---|
| 7 | |
---|
[190] | 8 | use Encode; |
---|
[187] | 9 | |
---|
| 10 | my $top = shift @ARGV || exit; |
---|
| 11 | if (! -d $top) { exit; } |
---|
| 12 | |
---|
[190] | 13 | my $utf8 = find_encoding("utf8"); |
---|
| 14 | |
---|
[187] | 15 | checkdir($top); |
---|
| 16 | |
---|
[188] | 17 | sub match { |
---|
[187] | 18 | my $str = shift @_; |
---|
| 19 | |
---|
[190] | 20 | my $sjis = encode("cp932", $utf8->decode($str), Encode::FB_HTMLCREF); |
---|
[189] | 21 | if ($sjis =~ /&#\d{4,};/) { |
---|
[187] | 22 | return 1; |
---|
| 23 | } |
---|
| 24 | |
---|
| 25 | return ''; |
---|
| 26 | } |
---|
| 27 | |
---|
| 28 | sub checkdir { |
---|
| 29 | my $target = shift @_; |
---|
| 30 | |
---|
| 31 | print STDERR "checking '$target'\n"; |
---|
| 32 | opendir(my $dir, $target) || return $target; |
---|
| 33 | my @entries = sort readdir($dir); |
---|
| 34 | closedir($dir); |
---|
| 35 | |
---|
| 36 | my @dirs; |
---|
| 37 | while (my $entry = shift @entries) { |
---|
| 38 | next if ($entry =~ /^\.+$/); |
---|
[188] | 39 | if (match($entry)) { |
---|
[189] | 40 | print "'$target/$entry' contains non Shift_JIS character\n"; |
---|
[187] | 41 | next; |
---|
| 42 | } |
---|
| 43 | if (-d "$target/$entry") { |
---|
| 44 | push @dirs, $entry; |
---|
| 45 | next; |
---|
| 46 | } |
---|
| 47 | } |
---|
| 48 | |
---|
| 49 | while (my $entry = pop @dirs) { |
---|
| 50 | checkdir("$target/$entry"); |
---|
| 51 | } |
---|
| 52 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.