Message415146
There are multiple "locale encodings":
* "current" locale encoding: locale.nl_langinfo(locale.CODESET)
* "Python" locale encoding: locale.getpreferredencoding(False), ignore the locale in UTF-8 Mode (always return "UTF-8"), ignore the locale on Android and VxWorks (always return "UTF-8")
* Python "filesystem" encoding: similar to the Python locale encoding, but always use UTF-8 on Android, macOS and VxWorks
Include/pyport.h:
---
#if defined(__ANDROID__) || defined(__VXWORKS__)
// Use UTF-8 as the locale encoding, ignore the LC_CTYPE locale.
// See _Py_GetLocaleEncoding(), PyUnicode_DecodeLocale()
// and PyUnicode_EncodeLocale().
# define _Py_FORCE_UTF8_LOCALE
#endif
#if defined(_Py_FORCE_UTF8_LOCALE) || defined(__APPLE__)
// Use UTF-8 as the filesystem encoding.
// See PyUnicode_DecodeFSDefaultAndSize(), PyUnicode_EncodeFSDefault(),
// Py_DecodeLocale() and Py_EncodeLocale().
# define _Py_FORCE_UTF8_FS_ENCODING
#endif
---
See bpo-43552 "Add locale.get_locale_encoding() and locale.get_current_locale_encoding()" (rejected).
Marc-Andre Lemburg dislikes locale.getpreferredencoding(False) API and suggested adding a new function locale.getencoding() with no argument:
https://bugs.python.org/issue46659#msg412667 |
|
Date |
User |
Action |
Args |
2022-03-14 15:01:37 | vstinner | set | recipients:
+ vstinner, ezio.melotti, methane |
2022-03-14 15:01:37 | vstinner | set | messageid: <1647270097.22.0.570841017393.issue47000@roundup.psfhosted.org> |
2022-03-14 15:01:37 | vstinner | link | issue47000 messages |
2022-03-14 15:01:37 | vstinner | create | |
|