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
.. 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``.
.. 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
.. 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``.
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__)
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__)