Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Win32 FileSystem codepage

by Khariton (Sexton)
on Dec 06, 2010 at 20:16 UTC ( #875686=perlquestion: print w/replies, xml ) Need Help??
Khariton has asked for the wisdom of the Perl Monks concerning the following question:

How I can get information about filesystem codepage in Win32?
For example, in Windows with cyrylic MUI, system use cp1251 codepage for filesystem.
For working with international file- and pathnames I need know about codepage of filesystem.
My program use UTF-8 for internal working(Tk and other...) and I must encode names from filesystem codepage to internal UTF-8. I use utf-8 in Linux , but in Win32 I must using a lot of codepages for work with international filenames...

Replies are listed 'Best First'.
Re: Win32 FileSystem codepage
by ikegami (Pope) on Dec 06, 2010 at 20:37 UTC
    • Windows:

      You can obtain the ANSI code page using GetACP. It's trivial to write Win32::API glue for that function.

      For existing files, you can use Win32::GetANSIPathName.

    • Unix:

      open's ":locale" uses the following to determine the appropriate encoding:

      require encoding; $locale_encoding = encoding::_get_locale_encoding();

    I don't know if anyone got around to making this usable.

Re: Win32 FileSystem codepage
by SimonClinch (Deacon) on Dec 09, 2010 at 00:37 UTC
    You could use Win32::CodePage and/or Win32::Locale

    One world, one people

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://875686]
Approved by ww
Front-paged by ikegami
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2017-03-28 00:50 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (326 votes). Check out past polls.