Dang. I need to add CreateFileW() to Win32API::File... ): I thought I had but it was Win32API::Registry that included the *W hooks...

Update: Short of that, I think you are stuck with only 8-bit characters when using open. So your options are likely:

  1. Switch to a locale where the file name only requires 8-bit characters
  2. Use the "short name" to open the file (at least I think that will work around this problem
  3. Rename the file (or, under NTFS, provide a hard link to the file using a name w/o problematic characters)

It is too bad that Win32.pm includes GetShortPathName() [which is GetShortPathNameA()] but not GetShortPathNameW().

Update: Yep, I checked the latest Perl source code and open under Win32 hasn't been made smart enough to handle UTF-8 strings.

ikegami mentioned (in the CB) using Win32::API to get access to CreateFileW(), which you could combine with Win32API::File's OsFHandleOpen() to get a Perl file handle to use.

- tye        


In reply to Re: Problems Opening file with Perl where path has UTF8 (sorry) by tye
in thread Problems Opening file with Perl where path has UTF8 by lustyx

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.