How to read a file with a long file name using unicode in Strawberry perl without using Win32 :: Unicode :: File?

I have a file located in a directory with Danish characters in it on a computer running Windows XP. I am using Strawberry perl and would like to read this file. The following code works fine:

    use Win32::Unicode::File;
    # Some code left out....
    $fname = $mw -> getOpenFile(-filetypes=>$types);
    my $fh = Win32::Unicode::File->new;
    $fh->open('<', $fname);

The getOpenFile procedure comes from Tk. Now, for some reason, Win32 :: Unicode :: File has some adverse side effects that I can't live with (it eats my memory, see "Not enough memory" with a simple Win32 :: Unicode :: File Reading and Strawberry Loop Perl ). Now, if I try to open a file without the Win32 :: Unicode :: File interface, I get a file not found. The reason for this is because the path is misinterpreted. I tried converting the path according to Perl: managing path encodings on Windows , which for some reason does not work. How do i solve this? I tried the following:

    use Encode;
    # Some code left out....
    $fname = $mw -> getOpenFile(-filetypes=>$types);
    my $fh;
    open($fh, '<', encode("utf8",$fname,Encode::FB_CROAK));

and it does not work. Any ideas?

Please forgive me if I do not understand.

Regards, Michael

+5
1
encode("utf8"

Perl - C Windows, Unicode (UTF-16 ), , - .

: UTF-8 UTF. , () ANSI. Windows cp-1252. , , , Win32::Codepage::get_encoding.

, , , , ANSI. ; , , , .

, Windows, , API Win32, Win32::Unicode::File. Perl; Unicode ​​ .

+5

All Articles