Commits

mattip committed ae93f80

revert changeset 727405791c06 to pass tests on narrow builds

Comments (0)

Files changed (1)

rpython/rlib/runicode.py

     ORD._flowspace_rewrite_directly_as_ = ord
 
 else:
-    UNICHR = unichr
-    ORD = ord
+    #UNICHR = unichr
+    #ORD = ord
+    def UNICHR(c):
+        if c <= sys.maxunicode and c <= MAXUNICODE:
+            return unichr(c)
+        else:
+            c -= 0x10000
+            return (unichr(0xD800 + (c >> 10)) +
+                    unichr(0xDC00 + (c & 0x03FF)))
+    
+    def ORD(u):
+        assert isinstance(u, unicode)
+        if len(u) == 1:
+            return ord(u[0])
+        elif len(u) == 2:
+            ch1 = ord(u[0])
+            ch2 = ord(u[1])
+            if 0xD800 <= ch1 <= 0xDBFF and 0xDC00 <= ch2 <= 0xDFFF:
+                return (((ch1 - 0xD800) << 10) | (ch2 - 0xDC00)) + 0x10000
+        raise ValueError
+
+def _STORECHAR(result, CH, byteorder):
+     hi = chr(((CH) >> 8) & 0xff)
+     lo = chr((CH) & 0xff)
 
 if MAXUNICODE > 0xFFFF:
     def code_to_unichr(code):