bpo-29240: PyUnicode_DecodeLocale() uses UTF-8 on Android (#5272)

PyUnicode_DecodeLocaleAndSize(), PyUnicode_DecodeLocale() and
PyUnicode_EncodeLocale() now use always use the UTF-8 encoding on
Android, instead of the current locale encoding.

On Android API 19, mbstowcs() and wcstombs() are broken and cannot be
used.
This commit is contained in:
Victor Stinner 2018-01-22 19:07:32 +01:00 committed by GitHub
parent 13ff24582c
commit 9089a26591
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 4 deletions

View file

@ -449,7 +449,12 @@ _Py_DecodeLocaleEx(const char* arg, wchar_t **wstr, size_t *wlen,
int current_locale, int surrogateescape)
{
if (current_locale) {
#ifdef __ANDROID__
return _Py_DecodeUTF8Ex(arg, strlen(arg), wstr, wlen, reason,
surrogateescape);
#else
return decode_current_locale(arg, wstr, wlen, reason, surrogateescape);
#endif
}
#if defined(__APPLE__) || defined(__ANDROID__)
@ -605,8 +610,13 @@ encode_locale_ex(const wchar_t *text, char **str, size_t *error_pos,
int raw_malloc, int current_locale, int surrogateescape)
{
if (current_locale) {
#ifdef __ANDROID__
return _Py_EncodeUTF8Ex(text, str, error_pos, reason,
raw_malloc, surrogateescape);
#else
return encode_current_locale(text, str, error_pos, reason,
raw_malloc, surrogateescape);
#endif
}
#if defined(__APPLE__) || defined(__ANDROID__)