diff Include/unicodeobject.h @ 73793:351cdf87bed0

Py_UNICODE_HIGH_SURROGATE() and Py_UNICODE_LOW_SURROGATE() macros And use surrogates macros everywhere in unicodeobject.c
author Victor Stinner <victor.stinner@haypocalc.com>
date Tue, 29 Nov 2011 22:58:13 +0100
parents 98b8849d1a30
children d36c4ec5342b
line wrap: on
line diff
--- a/Include/unicodeobject.h	Tue Nov 29 22:47:11 2011 +0100
+++ b/Include/unicodeobject.h	Tue Nov 29 22:58:13 2011 +0100
@@ -187,6 +187,10 @@
 #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. */