in reply to Can't Find File When Non-ASCII Letters Appear in Path

PS: Of course, I'm not using html entities but the corresponding unicode characters.

Perhaps your filesystem doesn't encode filenames using UTF-8. I'd try opening up the directory with opendir() and looking at what readdir() produces for the files in question. Most likely you'll have to produce the same thing to open the file.

-sam

  • Comment on Re: Can't Find File When Non-ASCII Letters Appear in Path

Replies are listed 'Best First'.
Re^2: Can't Find File When Non-ASCII Letters Appear in Path
by emav (Pilgrim) on Apr 16, 2007 at 18:22 UTC
    Thanks for the reply, Sam!

    Well, perhaps I should have mentioned that I resorted to UTF-8 after having tried Windows-1253 and ISO-8859-7. I even created a Wx::FileDialog object to make sure I'm getting the right path/filename but to no avail.

    Of course, there is no problem when plain English letters only appear in the path.
      Did you try UTF-16? I have some vague recollection that it's a popular encoding for Windows filesystems. Wikipedia seems to agree: UTF-16.

      -sam

        It's actually UCS-2le. UCS-2 is UTF-16's predecessor. While very similar, UCS-2 can only represent a subset of the characters that can be represented by UTF-16 because UCS-2 uses a fixed number of bytes for each char (2), while UTF-16 uses a variable number of bytes for each char (2, 4, ...?).

        Update: oh, I should have read your link in more carefully. It may have changed in newer version of Windows. I wonder if wcslen (strlen for wide chars) returns a number of chars of number of bytes divided by two.

        I had never heard of that. Worst still, I have never worked with utf-16. This is my first attempt:
        #!/usr/bin/perl -w use strict; use Unicode::String qw(utf8 latin1 utf16); my $u = utf8("C:\\&#913;&#957;&#964;&#943;&#947;&#961;&#945;&#966;&#95 +9;\\VOLINFO.TXT"); my $file = $u->utf16; open FILE, $file or die "can't open $file: $!"; while (<FILE>) { } close FILE;
        I only got this incomplete reaction from activeperl: can't open