Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

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 lurking in the Monastery: (4)
As of 2018-07-23 02:35 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (459 votes). Check out past polls.