Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

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 the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2016-10-27 02:03 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (352 votes). Check out past polls.