in reply to utf8 filenames

did you try to
use utf8 ; # Convert a Perl scalar to/from UTF-8. $num_octets = utf8::upgrade($string); $success = utf8::downgrade($string[, FAIL_OK]);
You'll findmany more gory details in "perldoc utf8".

Replies are listed 'Best First'.
Re^2: utf8 filenames
by cjk32 (Novice) on Apr 10, 2006 at 13:58 UTC
    I've just tried:
    use utf8; ex("c:\\fil\x{e9}.txt"); ex("c:\\fil" . pack("U", 0xe9 ) . ".txt"); sub ex { my $f2 = shift; my $f = $f2; print $f; print ((-e $f) ? " exists" : " doesn't exist"); print "\n"; my $f = $f2; utf8::upgrade($f); print $f; print ((-e $f) ? " exists" : " doesn't exist"); print "\n"; my $f = $f2; utf8::downgrade($f); print $f; print ((-e $f) ? " exists" : " doesn't exist"); print "\n\n"; }
    which produces:
    c:\filé.txt exists c:\filé.txt doesn't exist c:\filé.txt exists c:\filé.txt doesn't exist c:\filé.txt doesn't exist c:\filé.txt exists
    Is utf8::downgrade always guaranteed to produce a string with the required encoding for any environment though?
      Is utf8::downgrade always guaranteed to produce a string with the required encoding for any environment though?

      No, it just convert UTF-8 back to Latin1 (or EBCDIC in case you're using an A/400 or S/390). It simply looks like your file names are encoded in Latin1 on your drives. IIRC windows 2000 used Latin1, while Windows XP uses utf8. I may be wrong though because I'm a strict Un*x/Linux guy :)