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 lemburg
Recipients AndersMunch, lemburg, paul.moore, steve.dower, swt2c, tim.golden, zach.ware
Date 2021-02-17.12:18:38
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <e43ea347-2187-2b6d-7ca6-349cabf7134d@egenix.com>
In-reply-to <1613561775.0.0.643680445021.issue43115@roundup.psfhosted.org>
Content
On 17.02.2021 12:36, Anders Munch wrote:
> getlocale is documented to return None for the encoding if no encoding can be determined.  There's no need to guess.

Well, not quite... the documentation says that None can be returned,
not that it will return None in such cases.

What happens is that the value returned by the C lib's setlocale()
is normalized and parsed. If it doesn't include an encoding,
the table locale_alias is used to provide an encoding. If this
table does not include the locale, you get the ValueError.

We could enhance this to return None for the encoding instead
of raising an exception, but would this really help ?

Alternatively, we could add "en_DE" to the alias table and set
a default encoding to use. I assume this would have to be
ISO8859-15. OTOH, Windows supports UTF-8 for all locales in
more recent Windows versions, so perhaps we should use UTF-8
instead.

BTW: What is wxWidgets doing with the returned values ?

Resources:
- setlocale() in Visual C++ on Windows:

https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/setlocale-wsetlocale?view=msvc-160
- locale name formats supported by Windows CRT:

https://docs.microsoft.com/en-us/cpp/c-runtime-library/locale-names-languages-and-country-region-strings?view=msvc-160
- Language locale tags known by Windows:

https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-lcid/a9eac961-e77d-41a6-90a5-ce1a8b0cdb9c
- UTF8 support in Windows CRT:

https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/setlocale-wsetlocale?view=msvc-160#utf-8-support
History
Date User Action Args
2021-02-17 12:18:38lemburgsetrecipients: + lemburg, paul.moore, tim.golden, zach.ware, steve.dower, swt2c, AndersMunch
2021-02-17 12:18:38lemburglinkissue43115 messages
2021-02-17 12:18:38lemburgcreate