in reply to Unicode in filenames (part 2)

my $filename = "\x{4e2d}\x{63f7}"; # or any other way of creating utf8 string my $ret = CreateFileW(encode("utf16le", $filename . "\0"), GENERIC_WRITE, FILE_SHARE_READ, [], CREATE_ALWAYS, FILE_ATTRIBUTE_NO +RMAL, 0);

Replies are listed 'Best First'.
Re^2: Unicode in filenames (part 2)
by Anonymous Monk on Mar 21, 2006 at 08:41 UTC

    Thank you, Thelonius! That works great.

    Obviously, the module documentation needs fixing. How do I go about that?

    Any idea why the three createFile calls are failing?

      I would send any change requests to the module author, tyemq@cpan.org and the libwin32 maintainer, jand@activestate.com.

      Change requests are more likely to be made expeditiously if you submit them as patches (another Larry Wall claim to fame).

      Calling createFile with just the file name defaults to "r ke" access, i.e. GENERIC_READ, OPEN_EXISTING.

      Did the files exist?

      createFile() probably wraps CreateFileA() which is the single byte version.