Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^2: Directory operations and Unicode

by nikosv (Hermit)
on Nov 06, 2011 at 05:21 UTC ( #936241=note: print w/ replies, xml ) Need Help??


in reply to Re: Directory operations and Unicode
in thread Directory operations and Unicode

When using Win32::COM I subsequently use the OS COM facilities, hence I bypass any Wide APIs, call the Scripting.FileSystemObject and access the filesystem in UTF:

Win32::OLE->Option(CP => Win32::OLE::CP_UTF8); $obj = Win32::OLE->new('Scripting.FileSystemObject');
and manipulate its methods, for example :
$folder = $obj->GetFolder("."); $collection= $folder->{Files};
If you want to keep your sanity do not start looking into the wide API's ! :)


Comment on Re^2: Directory operations and Unicode
Select or Download Code
Replies are listed 'Best First'.
Re^3: Directory operations and Unicode
by afoken (Prior) on Nov 08, 2011 at 13:44 UTC
    When using Win32::COM I subsequently use the OS COM facilities, hence I bypass any Wide APIs, call the Scripting.FileSystemObject and access the filesystem in UTF

    No. You don't bypass the Wide APIs, you wrap them using a ridiculously large stack of other APIs. After uselessly burning a lot of CPU cycles, the Scripting.FileSystemObject finally ends calling the Wide APIs.

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
      hence I bypass any Wide APIs

      in the sense that I don't have to deal or think about them them

      you wrap them using a ridiculously large stack of other APIs. After uselessly burning a lot of CPU cycles

      might be true but it gets the job done. what is your suggestion of doing it otherwise ?

        what is your suggestion of doing it otherwise ?

        Using the "wide" API directly, of course. As long as Perl is compiled as an ANSI application, the only way to do so is to write a module, either using XS or Win32::API. Perl can handle Unicode, the only annoyance is that Perl currently uses a different encoding than Windows, so each and every wrapper function that passes strings from and to Windows needs to convert the strings. DBD::ODBC is an example for this; compiled on Windows, it prefers the "wide" API for ODBC, unless explicitly disabled.

        Alexander

        --
        Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://936241]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (9)
As of 2015-07-30 03:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (269 votes), past polls