Always use PyUnicode_DecodeUTF16 for 16 bit conversion; version-->2.2.3
authorrobin
Tue, 24 Aug 2021 11:31:46 +0100
changeset 96 1f2be2198067
parent 95 ca1fbee6a03c
child 97 5fef5844f833
Always use PyUnicode_DecodeUTF16 for 16 bit conversion; version-->2.2.3
src/pyRXP.c
--- a/src/pyRXP.c	Tue Aug 24 11:27:45 2021 +0100
+++ b/src/pyRXP.c	Tue Aug 24 11:31:46 2021 +0100
@@ -22,7 +22,7 @@
 #include "stdio16.h"
 #include "version.h"
 #include "namespaces.h"
-#define VERSION "2.2.2"
+#define VERSION "2.2.3"
 #define MAX_DEPTH 256
 #if PY_VERSION_HEX < 0x02050000
 #	define Py_ssize_t int
@@ -115,17 +115,12 @@
 PyObject* _PYSTRING(const Char* s, int utf8)
 {
 	int	lens = (int)Strlen(s);
-#if defined(Py_UNICODE_WIDE)
 	PyObject *u, *x;
 	u = PyUnicode_DecodeUTF16((char*)s,2*lens,NULL,NULL);
 	if(!utf8 || !u) return u;
 	x = PyUnicode_AsUTF8String(u);
 	Py_DECREF(u);
 	return x;
-#else
-	return utf8 ? PyUnicode_EncodeUTF8((Py_UNICODE*)s, lens, NULL)
-				: PyUnicode_FromUnicode((Py_UNICODE*)s, lens);
-#endif
 }
 #	define PYSTRING(s) _PYSTRING(s,utf8)
 PyObject* PYSTRING8(const char* s)