[Tutor] Question about language code
eryksun
eryksun at gmail.com
Fri Oct 12 06:37:31 CEST 2012
On Thu, Oct 11, 2012 at 11:12 PM, Dae James <daedae11 at 126.com> wrote:
>
>>>> import locale
>>>> loc = locale.getlocale() # get current locale
> # use German locale; name might vary with platform
>>>> locale.setlocale(locale.LC_ALL, 'de_DE')
This depends on the C runtime. For Windows, see MSDN:
setlocale
http://msdn.microsoft.com/en-us/library/x99tb11d
Language strings
http://msdn.microsoft.com/en-us/library/39cwe7zf
Country/Region strings
http://msdn.microsoft.com/en-us/library/cdax410z
Code pages
http://msdn.microsoft.com/en-us/library/cc195051
For example (untested):
>>> locale.setlocale(locale.LC_ALL, 'German_Germany.1252')
>From the MSDN setlocale() docs:
The "locale" argument can be formatted as follows:
setlocale( LC_ALL, "" );
Sets the locale to the default, which is the user-default ANSI code
page obtained from the operating system.
setlocale( LC_ALL, ".OCP" );
Explicitly sets the locale to the current OEM code page obtained from
the operating system.
setlocale( LC_ALL, ".ACP" );
Sets the locale to the ANSI code page obtained from the operating system.
setlocale( LC_ALL, "[lang_ctry]" );
Sets the locale to the language and country/region indicated, using
the default code page obtained from the host operating system.
setlocale( LC_ALL, "[lang_ctry.cp]" );
Sets the locale to the language, country/region, and code page
indicated in the [lang_ctry.cp] string. You can use various
combinations of language, country/region, and code page.
For example:
setlocale( LC_ALL, "French_Canada.1252" );
// Set code page to French Canada ANSI default
setlocale( LC_ALL, "French_Canada.ACP" );
// Set code page to French Canada OEM default
setlocale( LC_ALL, "French_Canada.OCP" );
More information about the Tutor
mailing list