diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2018-01-22 18:07:32 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-22 18:07:32 (GMT) |
commit | 9089a265918754d95e105a7c4c409ac9352c87bb (patch) | |
tree | 1f171191126bbe95f5e36de0a128b29bd7ed66b4 /Python/fileutils.c | |
parent | 13ff24582c99dfb439b1af7295b401415e7eb05b (diff) | |
download | cpython-9089a265918754d95e105a7c4c409ac9352c87bb.zip cpython-9089a265918754d95e105a7c4c409ac9352c87bb.tar.gz cpython-9089a265918754d95e105a7c4c409ac9352c87bb.tar.bz2 |
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.
Diffstat (limited to 'Python/fileutils.c')
-rw-r--r-- | Python/fileutils.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Python/fileutils.c b/Python/fileutils.c index 9a1435c..d610639 100644 --- a/Python/fileutils.c +++ b/Python/fileutils.c @@ -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__) |