summaryrefslogtreecommitdiffstats
path: root/Include/unicodeobject.h
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-11-29 21:58:13 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-11-29 21:58:13 (GMT)
commit551ac957331ff7f2a08436198b73f9c0245987e0 (patch)
tree65cd2b47407e28711ce3fd041a9f0b3a22b7171e /Include/unicodeobject.h
parent7b578b3d8973508863eb8e7b7151e3dd53f2cd79 (diff)
downloadcpython-551ac957331ff7f2a08436198b73f9c0245987e0.zip
cpython-551ac957331ff7f2a08436198b73f9c0245987e0.tar.gz
cpython-551ac957331ff7f2a08436198b73f9c0245987e0.tar.bz2
Py_UNICODE_HIGH_SURROGATE() and Py_UNICODE_LOW_SURROGATE() macros
And use surrogates macros everywhere in unicodeobject.c
Diffstat (limited to 'Include/unicodeobject.h')
-rw-r--r--Include/unicodeobject.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/Include/unicodeobject.h b/Include/unicodeobject.h
index e1a5a2f..836bafb 100644
--- a/Include/unicodeobject.h
+++ b/Include/unicodeobject.h
@@ -187,6 +187,10 @@ typedef unsigned char Py_UCS1;
#define Py_UNICODE_JOIN_SURROGATES(high, low) \
(((((Py_UCS4)(high) & 0x03FF) << 10) | \
((Py_UCS4)(low) & 0x03FF)) + 0x10000)
+/* high surrogate = top 10 bits added to D800 */
+#define Py_UNICODE_HIGH_SURROGATE(ch) (0xD800 | (((ch) - 0x10000) >> 10))
+/* low surrogate = bottom 10 bits added to DC00 */
+#define Py_UNICODE_LOW_SURROGATE(ch) (0xDC00 | (((ch) - 0x10000) & 0x3FF))
/* Check if substring matches at given offset. The offset must be
valid, and the substring must not be empty. */