in reply to Handling accented characters in filenames on Win32

What version of perl are you running? 5.8 should automatically handle UTF stuff. If it doesn't work there, you probably found a bug.

----
: () { :|:& };:

Note: All code is untested, unless otherwise stated

Replies are listed 'Best First'.
Re: Re: Handling accented characters in filenames on Win32
by Schlika (Initiate) on Apr 16, 2004 at 08:23 UTC
    Hi,

    Thanks for the feedback.
    I'm running ActiveState Perl v5.8.3.
    glob also returns rubbish when looking at the filename (prints ÜtÜ instead of été for example), but somehow if I use the paths returned by glob, the handles work...

    Schlika.
Re: Re: Handling accented characters in filenames on Win32
by Schlika (Initiate) on Apr 16, 2004 at 15:14 UTC
    Me again,

    It looks like what is coming out of `dir /a:d /s /b $path` is encoded in cp437.
    So if I use use encoding 'cp437';, I can see that the pathname is stored correctly with the accented characters.
    Yet if I try to then use this pathname with any functions (such as a print), it becomes rubbish again...

    Schlika.
Re: Re: Handling accented characters in filenames on Win32
by Schlika (Initiate) on Apr 19, 2004 at 20:14 UTC
    Howdie,

    In the end, the solution to my problem was to use an internal Perl command rather than a system call to a shell command as suggested by someone else in this thread.
    File::Find replaced 'dir' nicely.

    However, as with glob, File::Find would print funny characters instead of the proper accented characters...
    The trick is then to use Win32::Console and add Win32::Console::OutputCP(1252); somewhere in your code.
    This formats output to the Win32 console to code page 1252 which seems to be the correct type.

    Thanks for the helpful suggestions.

    Schlika.