in reply to Re: utf8 filenames
in thread utf8 filenames

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?

Replies are listed 'Best First'.
Re^3: utf8 filenames
by wazoox (Prior) on Apr 10, 2006 at 17:58 UTC
    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 :)