8 unless (defined &Win32::BuildNumber && Win32::BuildNumber() >= 820 or $] >= 5.008009) {
9 print "1..0 # Skip: Needs ActivePerl 820 or Perl 5.8.9 or later\n";
12 unless ((Win32::FsType())[1] & 4) {
13 print "1..0 # Skip: Filesystem doesn't support Unicode\n";
16 unless ((Win32::GetOSVersion())[1] > 4) {
17 print "1..0 # Skip: Unicode support requires Windows 2000 or later\n";
22 my $home = Win32::GetCwd();
23 my $cwd = cwd(); # may be a Cygwin path
24 my $dir = "Foo \x{394}\x{419} Bar \x{5E7}\x{645} Baz";
25 my $file = "$dir\\xyzzy \x{394}\x{419} plugh \x{5E7}\x{645}";
29 my $ansi = Win32::GetANSIPathName($file);
30 unlink($ansi) if -f $ansi;
31 $ansi = Win32::GetANSIPathName($dir);
32 rmdir($ansi) if -d $ansi;
40 # Create Unicode directory
41 Win32::CreateDirectory($dir);
42 ok(-d Win32::GetANSIPathName($dir));
45 Win32::CreateFile($file);
46 ok(-f Win32::GetANSIPathName($file));
48 # readdir() returns ANSI form of Unicode filename
49 ok(opendir(my $dh, Win32::GetANSIPathName($dir)));
50 while ($_ = readdir($dh)) {
52 ok($file, Win32::GetLongPathName("$dir\\$_"));
56 # Win32::GetLongPathName() of the absolute path restores the Unicode dir name
57 my $full = Win32::GetFullPathName($dir);
58 my $long = Win32::GetLongPathName($full);
60 ok($long, Win32::GetLongPathName($home)."\\$dir");
62 # We can Win32::SetCwd() into the Unicode directory
63 ok(Win32::SetCwd($dir));
64 ok(Win32::GetLongPathName(Win32::GetCwd()), $long);
66 # cwd() also returns a usable ANSI directory name
69 # change back to home directory to make sure relative paths
70 # in @INC continue to work
72 ok(Win32::GetCwd(), $home);
74 # cwd() on Cygwin returns a mapped path that we need to translate
75 # back to a Windows path. Invoking `cygpath` on $subdir doesn't work.
76 if ($^O eq "cygwin") {
77 chomp(my $cygpath = `cygpath -w "$cwd"`);
78 $subdir =~ s,\Q$cwd\E,$cygpath,;
81 ok(Win32::GetLongPathName($subdir), $long);
83 # We can chdir() into the Unicode directory if we use the ANSI name
84 ok(chdir(Win32::GetANSIPathName($dir)));
85 ok(Win32::GetLongPathName(Win32::GetCwd()), $long);