Last change
on this file was 23830, checked in by ak19, 13 years ago |
Fixed a minor off by one error: wide characters printed as unicode if greater than 127 instead of 128.
|
File size:
1.2 KB
|
Line | |
---|
1 | #!/usr/bin/perl -w
|
---|
2 |
|
---|
3 |
|
---|
4 | use Encode;
|
---|
5 |
|
---|
6 | sub debug_unicode_string
|
---|
7 | {
|
---|
8 | join("",
|
---|
9 | map { $_ > 127 ? # if wide character...
|
---|
10 | sprintf("\\x{%04X}", $_) : # \x{...}
|
---|
11 | chr($_)
|
---|
12 | } unpack("U*", $_[0])); # unpack Unicode characters
|
---|
13 | }
|
---|
14 |
|
---|
15 |
|
---|
16 | if (scalar(@ARGV)!=1) {
|
---|
17 | my $prog_name = $0;
|
---|
18 | $prog_name =~ s/^.*(\\|\/)//;
|
---|
19 |
|
---|
20 | print STDERR "Usage: $prog_name dir\n";
|
---|
21 | exit(1);
|
---|
22 | }
|
---|
23 |
|
---|
24 | my $dir = $ARGV[0];
|
---|
25 |
|
---|
26 | opendir(DIN,"$dir")
|
---|
27 | || die "Unable to open $dir";
|
---|
28 |
|
---|
29 | my @files = grep { $_ !~ m/^\./ } readdir(DIN);
|
---|
30 |
|
---|
31 | close(DIN);
|
---|
32 |
|
---|
33 | foreach my $f (@files)
|
---|
34 | {
|
---|
35 | print "Filename as is: $f\n";
|
---|
36 | print "Filename debug: ", debug_unicode_string($f),"\n";
|
---|
37 |
|
---|
38 | my $dirsep = ($^O =~ /mswin/i) ? "\\" : "/";
|
---|
39 |
|
---|
40 | $f =~ s@$dirsep$@@;
|
---|
41 |
|
---|
42 | my $full_f = "$dir$dirsep$f";
|
---|
43 | if ($^O =~ /mswin/i) {
|
---|
44 | require Win32;
|
---|
45 | $full_f = Win32::GetLongPathName($full_f);
|
---|
46 | #$full_f = encode("UTF8",$full_f);
|
---|
47 | print "Windows full filename: ", $full_f,"\n";
|
---|
48 | print "Windows full filename debug: ", debug_unicode_string($full_f),"\n";
|
---|
49 |
|
---|
50 | $full_f = Win32::GetShortPathName($full_f);
|
---|
51 | }
|
---|
52 |
|
---|
53 | if ( -e $full_f ) {
|
---|
54 | print " Perl can see file $full_f\n";
|
---|
55 | }
|
---|
56 | else {
|
---|
57 | print " Perl CANNOT see $full_f\n";
|
---|
58 | }
|
---|
59 | }
|
---|
60 |
|
---|
61 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.