On Thu, 19 Apr 2007, Glenn Linderman wrote:
> Perlrun sez:
>
> > (In Perls earlier than 5.8.1 the |-C| switch was a Win32-only switch
> > that enabled the use of Unicode-aware ``wide system call'' Win32
> > APIs. This feature was practically unused, however, and the command
> > line switch was therefore ``recycled''.)
>
> But it isn't clear if
> 1) -C is replaced by a different parameter to do the old "wide system
>    call" stuff
> 2) the wide system call stuff still exists, or how it is invoked.
>
> Enquiring minds want to know...

No, the old "wide system stuff" has been removed.  It relied on filenames
being UCS-2 encoded byte strings, which did not really work well with
the Unicode implementation in 5.6.

You can use Win32API::File to do most of the operations by explicitly
converting filenames into wide character encodings:

  http://groups.google.com/group/perl.unicode/msg/86ab5af239975df7?hl=en&;

The major part missing is mkdir()/opendir() support (someone should
write Win32API::Directory if they really want this).

I found Win32API::File way to low-level and think Perl should deal with
Unicode file and directory names without additional effort by the user.
Unfortunately Perl uses only byte string interfaces for system calls,
so adding real Unicode support would be a lot of work.

As an alternative, I've modified the Perl internals on Windows to
automatically use the short (ANSI) filename when the long filename
cannot be represented in the current system codepage.  Using the
short filename is preferable, as forcing the long name into the
codepage will result in replacement characters, turning the name
unusable for anything but maybe display purposes.

In bleadperl (and 5.8.9) Cwd::cwd, glob(), readdir(), $^X, $0 etc will
all return useable filenames that can be passed to external processes or
passed to other system calls.

I've also just uploaded an alpha version of Win32 to CPAN that tries to
round out this functionality:

   http://search.cpan.org/~jdb/Win32-0.27_01/

Here is the list of changes:

0.27_01 [2007-04-12]
        - Update Win32::IsAdminUser() to use the IsUserAnAdmin() function
          in shell32.dll when available.  On Windows Vista this will only
          return true if the process is running with elevated privileges
          and not just when the owner of the process is a member of the
          "Administrators" group.

        - Win32::ExpandEnvironmentStrings() may return a Unicode string
          (a string containing characters outside the system codepage)

        - new Win32::GetANSIPathName() function returns a pathname in
          a form containing only characters from the system codepage

        - Win32::GetCwd() will return an ANSI version of the directory
          name if the long name contains characters outside the system
          codepage.

        - Win32::GetFolderPath() will return an ANSI pathname. Call
          Win32::GetLongPathName() to get the canonical Unicode
          representation.

        - Win32::GetFullPathName() will return an ANSI pathname. Call
          Win32::GetLongPathName() to get the canonical Unicode
          representation.

        - Win32::GetLongPathName() may return a Unicode path name.
          Call Win32::GetANSIPathName() to get a representation using
          only characters from the system codepage.

        - Win32::LoginName() may return a Unicode string.

        - new Win32::OutputDebugString() function sends a string to
          the debugger.

        - new Win32::GetCurrentThreadId() function returns the thread
          id (to complement the process id in $$).

        - new Win32::CreateDirectory() creates a new directory.  The
          name of the directory may contain Unicode characters outside
          the system codepage.

        - new Win32::CreateFile() creates a new file.  The name of the
          file may contain Unicode characters outside the system codepage.

I'll send a diff against 0.27 separately, as the search.cpan.org diff
doesn't show a useful diff for the .pm and .xs files (due to the use of
`diff -a` I think).

I would really welcome any feedback on 0.27_01 because I would like to
release 0.28 soon to get it into Perl 5.8.9 and 5.10.

I would especially like to hear if people think the changed functionality
for some functions "breaks" backward compatibility and would therefore be
unsuitable for 5.8.9!

Cheers,
-Jan


_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to