mirror of
https://github.com/python/cpython.git
synced 2025-07-24 03:35:53 +00:00
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:
parent
13ff24582c
commit
9089a26591
2 changed files with 17 additions and 4 deletions
|
@ -760,7 +760,8 @@ system.
|
|||
Py_ssize_t len, \
|
||||
const char *errors)
|
||||
|
||||
Decode a string from the current locale encoding. The supported
|
||||
Decode a string from UTF-8 on Android, or from the current locale encoding
|
||||
on other platforms. The supported
|
||||
error handlers are ``"strict"`` and ``"surrogateescape"``
|
||||
(:pep:`383`). The decoder uses ``"strict"`` error handler if
|
||||
*errors* is ``NULL``. *str* must end with a null character but
|
||||
|
@ -780,7 +781,7 @@ system.
|
|||
|
||||
.. versionchanged:: 3.7
|
||||
The function now also uses the current locale encoding for the
|
||||
``surrogateescape`` error handler. Previously, :c:func:`Py_DecodeLocale`
|
||||
``surrogateescape`` error handler, except on Android. Previously, :c:func:`Py_DecodeLocale`
|
||||
was used for the ``surrogateescape``, and the current locale encoding was
|
||||
used for ``strict``.
|
||||
|
||||
|
@ -795,7 +796,8 @@ system.
|
|||
|
||||
.. c:function:: PyObject* PyUnicode_EncodeLocale(PyObject *unicode, const char *errors)
|
||||
|
||||
Encode a Unicode object to the current locale encoding. The
|
||||
Encode a Unicode object to UTF-8 on Android, or to the current locale
|
||||
encoding on other platforms. The
|
||||
supported error handlers are ``"strict"`` and ``"surrogateescape"``
|
||||
(:pep:`383`). The encoder uses ``"strict"`` error handler if
|
||||
*errors* is ``NULL``. Return a :class:`bytes` object. *unicode* cannot
|
||||
|
@ -815,7 +817,8 @@ system.
|
|||
|
||||
.. versionchanged:: 3.7
|
||||
The function now also uses the current locale encoding for the
|
||||
``surrogateescape`` error handler. Previously, :c:func:`Py_EncodeLocale`
|
||||
``surrogateescape`` error handler, except on Android. Previously,
|
||||
:c:func:`Py_EncodeLocale`
|
||||
was used for the ``surrogateescape``, and the current locale encoding was
|
||||
used for ``strict``.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue