mirror of
https://github.com/python/cpython.git
synced 2025-11-25 21:11:09 +00:00
Issue #28596: The preferred encoding is UTF-8 on Android.
This commit is contained in:
parent
b06cde61a2
commit
6c9dcda6b4
3 changed files with 29 additions and 14 deletions
|
|
@ -618,15 +618,21 @@ else:
|
|||
try:
|
||||
CODESET
|
||||
except NameError:
|
||||
# Fall back to parsing environment variables :-(
|
||||
def getpreferredencoding(do_setlocale = True):
|
||||
"""Return the charset that the user is likely using,
|
||||
by looking at environment variables."""
|
||||
res = getdefaultlocale()[1]
|
||||
if res is None:
|
||||
# LANG not set, default conservatively to ASCII
|
||||
res = 'ascii'
|
||||
return res
|
||||
if hasattr(sys, 'getandroidapilevel'):
|
||||
# On Android langinfo.h and CODESET are missing, and UTF-8 is
|
||||
# always used in mbstowcs() and wcstombs().
|
||||
def getpreferredencoding(do_setlocale = True):
|
||||
return 'UTF-8'
|
||||
else:
|
||||
# Fall back to parsing environment variables :-(
|
||||
def getpreferredencoding(do_setlocale = True):
|
||||
"""Return the charset that the user is likely using,
|
||||
by looking at environment variables."""
|
||||
res = getdefaultlocale()[1]
|
||||
if res is None:
|
||||
# LANG not set, default conservatively to ASCII
|
||||
res = 'ascii'
|
||||
return res
|
||||
else:
|
||||
def getpreferredencoding(do_setlocale = True):
|
||||
"""Return the charset that the user is likely using,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue