SPUG: unicode filename problems

jlb jlb at io.com
Thu Mar 23 14:58:27 PST 2006


I'm trying to create filenames that contain some particular unicode 
characters.  The code I've written to do so work fine on the FreeBSD and 
Linux machine I'm using, but doesn't work the same way under ActiveState 
Perl.

I'm not all that well-versed in unicode-related issues, and I've tried 
looking through the various perl encoding docs but haven't seen anything 
promising.  I may just be missing some simple obvious step that I simply 
don't know about.

This code is basically what I'm doing, and it works fine everywhere but 
windows.

perl -e 'open (FILE, ">".pack("U", 0x2014)) || die "$!";'

Everywhere but windows this is creating a file named with the value of 
0xe28094, on windows I end up with something like 0xc3a2e282ace2809d.

I thought maybe it was an actual windows issue, but I was able to create 
the expected filenames using a similar bit of code in ActiveState python.

>>> fh = open(u"\u2014", 'w')

I was also able to create the files on Linux, then access them over Samba 
from the windows machine and make copies of the files, which maintained 
the correct names.

Any ideas where I might be going wrong?

I've tried playing around with the Encode module but it didn't seem to 
really get me anywhere, and I'm not sure it's really the answer.

The linux machine is using 5.8.0, the FreeBSD machine is using 5.6.0 and 
the windows machine is using ActiveState Perl 5.8.7 build 815.


More information about the spug-list mailing list