Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hello
What is wrong in the following code if I read a path from a utf-8 file (a ini file) and use this path to create a folder with non-latin characters on Windows (Perl 5.28) with Win32::CreateDirectory? If the same path is hardcoded, the folder is created correctly!
configStartup.ini is encoded in UTF-8 and has the following one line: ForceDirectoryData=D:/Test Ршзефф 号召力打了
use Win32; use utf8; my $configFile='configStartup.ini'; my $UserDataReadFromFile; open my $FH, '<:encoding(UTF-8)', $configFile; while (my $line = <$FH>) { if ($line =~/^ForceDirectoryData/){ (my $tag, $UserDataReadFromFile) = split(/=/, $line); } } close $FH; #1 the following doesn't work (dies) Win32::CreateDirectory ($UserDataReadFromFile) or die; #2 it works if hardcoded my $UserDataHardCoded='D:/Test Ршзеф
 +92; 号召力打了'; Win32::CreateDirectory ($UserDataHardCoded) or die;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Utf-8 path from file
by vr (Curate) on Feb 26, 2019 at 20:44 UTC | |
|
Re: Utf-8 path from file
by Anonymous Monk on Feb 26, 2019 at 19:55 UTC |