gh-74940: Allow fallback to UTF-8 encoding on systems with no locales installed (GH-14925)

This change removes the alias of the 'C' locale to 'en_US'. Because of
this alias, it is currently impossible for an application to use
setlocale() to specify a UTF-8 locale on a system that has no locales
installed, but which supports the C.UTF-8 locale/encoding.
This commit is contained in:
Gordon Messmer 2023-04-25 23:33:09 -07:00 committed by GitHub
parent 31acfd78a0
commit 2763994be3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

View file

@ -962,7 +962,7 @@ def getpreferredencoding(do_setlocale=True):
'c.ascii': 'C',
'c.en': 'C',
'c.iso88591': 'en_US.ISO8859-1',
'c.utf8': 'en_US.UTF-8',
'c.utf8': 'C.UTF-8',
'c_c': 'C',
'c_c.c': 'C',
'ca': 'ca_ES.ISO8859-1',

View file

@ -0,0 +1,2 @@
The C.UTF-8 locale is no longer converted to en_US.UTF-8, enabling the use
of UTF-8 encoding on systems which have no locales installed.