Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Re: Perl support for unicode file name handling

by Anonymous Monk
on Jan 25, 2004 at 18:00 UTC ( [id://323990]=note: print w/replies, xml ) Need Help??


in reply to Re: Perl support for unicode file name handling
in thread Perl support for unicode file name handling

Thanks, I have inserted some sample code
${^WIDE_SYSTEM_CALLS}; #use Encode; #use utf8; foreach $FILE ( `dir /B c:\\work\\intl-testout` ) #foreach $FILE ( `dir /B c:\\sigtools` ) { chomp($FILE); $FULLPATH = "c:/work/intl-testout/" . $FILE; #my $DECODE = decode("utf8",$FULLPATH); #if ( -e $DECODE ) #if ( -e $FULLPATH ) if ( -e $FULLPATH ) { print "DOS Dir listing File exists - $FULLPATH\n"; } else { print "DOS Dir listing File DOES NOT exist - $FULLPATH\n"; } } if ( ( opendir (HDIR,"c:/work/intl-testout" ) ) ) { while ( $FILE = readdir(HDIR) ) { $FULLPATH = "c:/work/intl-testout/" . $FILE; if ( -e $FULLPATH ) { print "Perl Dir listing File exists - $FULLPATH\n"; } else { print "Perl Dir listing File DOES NOT exist - $FULLPATH\n" +; } } } $FILE = q|c:/work/intl-testout/resumé.txt|; print "$FILE\n"; if ( -e $FILE ) { print "File exists\n"; } else { print "Can not find File\n"; }
The above code lists a directory with some files with wide characters in the file name. I test if the file exists with the "-e" test, which should always return true. When I test the files with the first loop using the dos file listing, none of the files are found with -e. When I test the files with the Perl readdir, some files are found with -e, while others are not. The final test works as well. I suspect the characters returned from DOS listing are being translated to another character set in Perl, and then Windows can not resolve the file name when used in the "-e" test. I not very familiar with unicode, or Perl for that matter.

Replies are listed 'Best First'.
Re^3: Perl support for unicode file name handling
by freonpsandoz (Beadle) on Jun 09, 2017 at 01:15 UTC

    I couldn't find any information on file globbing in Win32API::File. Nor can I find anything to explain what is meant by "magic of NTFS." Can someone explain that? Thanks.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://323990]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2024-04-19 13:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found