This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients eryksun, lemburg, methane, vstinner
Date 2021-03-19.13:47:36
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1616161656.73.0.605355864914.issue43552@roundup.psfhosted.org>
In-reply-to
Content
> - If you add "current", people will rightly ask: then what do all the
> other APIs in the locale module return ? Of course, they all return
> the current state of settings :-) So this is unnecessary as well.

The problem is that there are two different "locale encodings", what I call:

* "current locale encoding": nl_langinfo(CODESET) in short
* "Python locale encoding": "UTF-8" in some cases, nl_langinfo(CODESET) otherwise

It is unfortunate that the Python UTF-8 Mode which "ignores the locale" changes the behavior of the locale module, of the locale.getpreferredencoding() function. But the ship has sailed.

People are used to look into the "locale" module to get the "locale" encoding. So I prefer to put  the function to get the "Python locale encoding" in the locale module.

I propose to add "current" in the name since this encoding is not the one you are looking for usually.

An alternative is to have a single function with an optional parameter. Example:

* get_locale_encoding() or get_locale_encoding(True) returns the locale encoding
* get_locale_encoding(False) returns the current locale encoding
History
Date User Action Args
2021-03-19 13:47:36vstinnersetrecipients: + vstinner, lemburg, methane, eryksun
2021-03-19 13:47:36vstinnersetmessageid: <1616161656.73.0.605355864914.issue43552@roundup.psfhosted.org>
2021-03-19 13:47:36vstinnerlinkissue43552 messages
2021-03-19 13:47:36vstinnercreate