summaryrefslogtreecommitdiffstats
path: root/Python/bltinmodule.c
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2001-06-26 22:22:37 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2001-06-26 22:22:37 (GMT)
commit0ba70cc3c893f70cc9deb09447277539d7625403 (patch)
treef26c28cc3ad9c594683c7c04e5b06786471d395c /Python/bltinmodule.c
parentff1cc902fe80605fbc7d5fee8226e4c26832c5a9 (diff)
downloadcpython-0ba70cc3c893f70cc9deb09447277539d7625403.zip
cpython-0ba70cc3c893f70cc9deb09447277539d7625403.tar.gz
cpython-0ba70cc3c893f70cc9deb09447277539d7625403.tar.bz2
Support using UCS-4 as the Py_UNICODE type:
Add configure option --enable-unicode. Add config.h macros Py_USING_UNICODE, PY_UNICODE_TYPE, Py_UNICODE_SIZE, SIZEOF_WCHAR_T. Define Py_UCS2. Encode and decode large UTF-8 characters into single Py_UNICODE values for wide Unicode types; likewise for UTF-16. Remove test whether sizeof Py_UNICODE is two.
Diffstat (limited to 'Python/bltinmodule.c')
-rw-r--r--Python/bltinmodule.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index ed5519f..cb4a257 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -324,12 +324,16 @@ builtin_unichr(PyObject *self, PyObject *args)
s[0] = (Py_UNICODE) x;
return PyUnicode_FromUnicode(s, 1);
} else {
+#if Py_UNICODE_SIZE == 2
/* UCS-4 character. store as two surrogate characters */
x -= 0x10000L;
s[0] = 0xD800 + (Py_UNICODE) (x >> 10);
s[1] = 0xDC00 + (Py_UNICODE) (x & 0x03FF);
return PyUnicode_FromUnicode(s, 2);
+#endif
}
+ s[0] = (Py_UNICODE)x;
+ return PyUnicode_FromUnicode(s, 1);
}
static char unichr_doc[] =