summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorXavier de Gaye <xdegaye@users.sourceforge.net>2016-12-15 19:59:58 (GMT)
committerXavier de Gaye <xdegaye@users.sourceforge.net>2016-12-15 19:59:58 (GMT)
commit76febd079299d64abffee0bdd7c4c1785e5a0fa7 (patch)
tree517048da532d163551a4a349ad3b8f0e1e5514d8 /Python
parent3d3f264849580ab1e8f3a8e8e8ba402bfe2c6523 (diff)
downloadcpython-76febd079299d64abffee0bdd7c4c1785e5a0fa7.zip
cpython-76febd079299d64abffee0bdd7c4c1785e5a0fa7.tar.gz
cpython-76febd079299d64abffee0bdd7c4c1785e5a0fa7.tar.bz2
Issue #26919: On Android, operating system data is now always encoded/decoded
to/from UTF-8, instead of the locale encoding to avoid inconsistencies with os.fsencode() and os.fsdecode() which are already using UTF-8.
Diffstat (limited to 'Python')
-rw-r--r--Python/fileutils.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/Python/fileutils.c b/Python/fileutils.c
index 6a32c42..e84d66e 100644
--- a/Python/fileutils.c
+++ b/Python/fileutils.c
@@ -20,7 +20,7 @@ extern int winerror_to_errno(int);
#include <fcntl.h>
#endif /* HAVE_FCNTL_H */
-#ifdef __APPLE__
+#if defined(__APPLE__) || defined(__ANDROID__)
extern wchar_t* _Py_DecodeUTF8_surrogateescape(const char *s, Py_ssize_t size);
#endif
@@ -273,7 +273,7 @@ decode_ascii_surrogateescape(const char *arg, size_t *size)
wchar_t*
Py_DecodeLocale(const char* arg, size_t *size)
{
-#ifdef __APPLE__
+#if defined(__APPLE__) || defined(__ANDROID__)
wchar_t *wstr;
wstr = _Py_DecodeUTF8_surrogateescape(arg, strlen(arg));
if (size != NULL) {
@@ -406,7 +406,7 @@ oom:
if (size != NULL)
*size = (size_t)-1;
return NULL;
-#endif /* __APPLE__ */
+#endif /* __APPLE__ or __ANDROID__ */
}
/* Encode a wide character string to the locale encoding with the
@@ -424,7 +424,7 @@ oom:
char*
Py_EncodeLocale(const wchar_t *text, size_t *error_pos)
{
-#ifdef __APPLE__
+#if defined(__APPLE__) || defined(__ANDROID__)
Py_ssize_t len;
PyObject *unicode, *bytes = NULL;
char *cpath;
@@ -522,7 +522,7 @@ Py_EncodeLocale(const wchar_t *text, size_t *error_pos)
bytes = result;
}
return result;
-#endif /* __APPLE__ */
+#endif /* __APPLE__ or __ANDROID__ */
}