From 95d30af67bcbe14a0755e24c85400affc01eac20 Mon Sep 17 00:00:00 2001
From: Alexey Pavlov <alexpux@gmail.com>
Date: Thu, 28 Jun 2018 11:41:32 +0300
Subject: [PATCH 5/7] perl.cygwin-Win32

---
 cpan/Win32/t/GetShortPathName.t |  9 ++++++---
 cpan/Win32/t/Unicode.t          | 31 ++++++++++++++++---------------
 2 files changed, 22 insertions(+), 18 deletions(-)

diff --git a/cpan/Win32/t/GetShortPathName.t b/cpan/Win32/t/GetShortPathName.t
index 649420a..82ce2d5 100644
--- a/cpan/Win32/t/GetShortPathName.t
+++ b/cpan/Win32/t/GetShortPathName.t
@@ -12,18 +12,21 @@ BEGIN {
     }
 }
 
-my $path = "Long Path $$";
+my $path = "C:\\Long Path $$";
 unlink($path);
 END { unlink $path }
 
-plan tests => 5;
+plan tests => 7;
 
 Win32::CreateFile($path);
 ok(-f $path);
 
 my $short = Win32::GetShortPathName($path);
-ok($short, qr/^\S{1,8}(\.\S{1,3})?$/);
+ok($short, qr/^C:\\\S{1,8}(\.\S{1,3})?$/);
 ok(-f $short);
+my $long = Win32::GetLongPathName($short);
+ok($long, $path);
+ok(-f $long);
 
 unlink($path);
 ok(!-f $path);
diff --git a/cpan/Win32/t/Unicode.t b/cpan/Win32/t/Unicode.t
index c1380e8..fa05188 100644
--- a/cpan/Win32/t/Unicode.t
+++ b/cpan/Win32/t/Unicode.t
@@ -1,8 +1,9 @@
 use strict;
-use Test;
+use utf8;
+use Test::More;
 use Config qw(%Config);
 use Cwd qw(cwd);
-use Encode qw();
+use Encode qw(encode decode);
 use Win32;
 
 BEGIN {
@@ -27,10 +28,13 @@ BEGIN {
     }
 }
 
-my $home = Win32::GetCwd();
-my $cwd  = cwd(); # may be a Cygwin path
-my $dir  = "Foo \x{394}\x{419} Bar \x{5E7}\x{645} Baz";
-my $file = "$dir\\xyzzy \x{394}\x{419} plugh \x{5E7}\x{645}";
+my $home  = Win32::GetCwd();
+my $cwd   = cwd(); # may be a Cygwin path
+my $dir8  = "Foo ΔЙ Bar קم Baz"; #Foo \x{394}\x{419} Bar \x{5E7}\x{645} Baz";
+my $file8 = "$dir8\\xyzzy ΔЙ plugh קم"; #xyzzy \x{394}\x{419} plugh \x{5E7}\x{645}";
+my $dir   = encode("UTF-8", $dir8);
+my $file  = encode("UTF-8", $file8);
+
 
 sub cleanup {
     chdir($home);
@@ -43,32 +47,29 @@ sub cleanup {
 cleanup();
 END { cleanup() }
 
-plan test => 12;
+plan tests => 12;
 
 # Create Unicode directory
-Win32::CreateDirectory($dir);
+Win32::CreateDirectory($dir8);
 ok(-d Win32::GetANSIPathName($dir));
 
 # Create Unicode file
-Win32::CreateFile($file);
+Win32::CreateFile($file8);
 ok(-f Win32::GetANSIPathName($file));
 
 # readdir() returns ANSI form of Unicode filename
 ok(opendir(my $dh, Win32::GetANSIPathName($dir)));
 while ($_ = readdir($dh)) {
     next if /^\./;
-    # On Cygwin 1.7 readdir() returns the utf8 representation of the
-    # filename but doesn't turn on the SvUTF8 bit
-    Encode::_utf8_on($_) if $^O eq "cygwin" && $Config{osvers} !~ /^1.5/;
     ok($file, Win32::GetLongPathName("$dir\\$_"));
 }
 closedir($dh);
 
 # Win32::GetLongPathName() of the absolute path restores the Unicode dir name
-my $full = Win32::GetFullPathName($dir);
+my $full = Win32::GetFullPathName($dir8);
 my $long = Win32::GetLongPathName($full);
 
-ok($long, Win32::GetLongPathName($home)."\\$dir");
+ok($long, Win32::GetLongPathName($home)."\\".$dir);
 
 # We can Win32::SetCwd() into the Unicode directory
 ok(Win32::SetCwd($dir));
@@ -87,7 +88,7 @@ ok(Win32::GetLongPathName($w32dir), $long);
 # cwd() on Cygwin returns a mapped path that we need to translate
 # back to a Windows path. Invoking `cygpath` on $subdir doesn't work.
 if ($^O eq "cygwin") {
-    $subdir = Cygwin::posix_to_win_path($subdir, 1);
+    $subdir = decode "UTF-8", Cygwin::posix_to_win_path($subdir, 1);
 }
 $subdir =~ s,/,\\,g;
 # Cygwin64 no longer returns an ANSI name
-- 
2.37.1

