Is there a way to detect an environment's "default" encoding type (Windows)?

python at bdurham.com python at bdurham.com
Wed Mar 24 16:34:59 EDT 2010


Is there a way to detect an environment's "default" encoding type
under Windows? I'm not sure if code page and encoding mean the
same thing here.

For example: When I use Word on my US based version of Windows
and decide to save a file as text, I am prompted with an encoding
dialog that defaults to 'Windows (default)' which appears maps to
their 'Western European (Windows)' code page which I assume maps
to code page 1252. (That's a lot of assumptions!).

I would like to be able to make the same assumption about text
files produced on a user's system. (Of course our software will
offer a way to explictly specify an encoding format as well).

Here's what I've been able to dig up so far but I'm not sure how
reliable this is or if its the same information Word is looking
at when it offers a default encoding value.

>>> import locale
>>> locale.getdefaultlocale()[1]
'cp1252'

Any ideas?

Malcolm
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100324/2cb0e206/attachment.html>


More information about the Python-list mailing list