in reply to Mkdir and utf8

Windows has two set of system calls: "A"NSI and "W"ide.

Perl's file functions use the "A" version of the system call, so the UTF-8 encoding of the string you pass to them is interpreted as being encoded according to the system's code page (e.g. American systems typically use cp1252, Microsoft's version of iso-latin-1).

One way to achieve your goal is to encode the file name according to the system's code page.

#!/usr/bin/perl use utf8; use Encode qw( encode ); use Win32::Codepage; mkdir encode(Win32::Codepage::get_encoding(), 'Ïntêràtíonaliçzation');

That method assumes the characters you are using are present in your system's code page. If they are not, you will need to use the "W" version of the function. The "W" function accepts UCS-2le strings which can encode common UNICODE characters. Unfortunately, I don't think there currently exists a module that gives access to those functions, but you could access them via Win32::API.

Replies are listed 'Best First'.
Re^2: Mkdir and utf8
by perlmonkdr (Beadle) on Nov 08, 2007 at 00:11 UTC

    You right, the example that you give to us works exactly as you say on windows,i'm really not know that windows has two systems calls, i appreciate very much, the problem was finaly solved, i will also investigate the wide call.

    Thk U very much ikegami

      For example, the system call in question is CreateDirectory.

      BOOL WINAPI CreateDirectory( LPCTSTR lpPathName, LPSECURITY_ATTRIBUTES lpSecurityAttributes );

      If you read down that page, you'll see that it's "implemented as CreateDirectoryW (Unicode) and CreateDirectoryA (ANSI)". CreateDirectory is really just an alias for one of these two actual KERNEL32 functions. If you look in winbase.h, you'll find

      WINBASEAPI BOOL WINAPI CreateDirectoryA( LPCSTR lpPathName, LPSECURITY_ATTRIBUTES lpSecurityAttributes ); WINBASEAPI BOOL WINAPI CreateDirectoryW( LPCWSTR lpPathName, LPSECURITY_ATTRIBUTES lpSecurityAttributes ); #ifdef UNICODE #define CreateDirectory CreateDirectoryW #else #define CreateDirectory CreateDirectoryA #endif
      Win32API::File - Low-level access to Win32 system API calls for files/dirs.