[pypy-svn] r48632 - in pypy/branch/more-unicode-improvements/pypy/rlib: . test

cfbolz at codespeak.net cfbolz at codespeak.net
Tue Nov 13 10:05:41 CET 2007


Author: cfbolz
Date: Tue Nov 13 10:05:41 2007
New Revision: 48632

Modified:
   pypy/branch/more-unicode-improvements/pypy/rlib/runicode.py
   pypy/branch/more-unicode-improvements/pypy/rlib/test/test_runicode.py
Log:
test + fix


Modified: pypy/branch/more-unicode-improvements/pypy/rlib/runicode.py
==============================================================================
--- pypy/branch/more-unicode-improvements/pypy/rlib/runicode.py	(original)
+++ pypy/branch/more-unicode-improvements/pypy/rlib/runicode.py	Tue Nov 13 10:05:41 2007
@@ -332,7 +332,7 @@
                     if (0xDC00 <= ord(ch2) and ord(ch2) <= 0xDFFF) :
                         ch3 = ((ord(ch) - 0xD800) << 10 | (ord(ch2) - 0xDC00)) + 0x10000
                         i += 1
-                        _encodeUCS4(p, ch)
+                        _encodeUCS4(p, ord(ch))
                         continue
                 # Fall through: handles isolated high surrogates
                 p += (chr((0xe0 | (ord(ch) >> 12))))

Modified: pypy/branch/more-unicode-improvements/pypy/rlib/test/test_runicode.py
==============================================================================
--- pypy/branch/more-unicode-improvements/pypy/rlib/test/test_runicode.py	(original)
+++ pypy/branch/more-unicode-improvements/pypy/rlib/test/test_runicode.py	Tue Nov 13 10:05:41 2007
@@ -158,8 +158,11 @@
                 self.checkencode(unichr(i), encoding)
 
     def test_single_chars_utf8(self):
+        # check every number of bytes per char
         for s in ["\xd7\x90", "\xd6\x96", "\xeb\x96\x95", "\xf0\x90\x91\x93"]:
             self.checkencode(s, "utf-8")
+        # check replacing of two surrogates by single char while encoding
+        self.checkencode(u"\ud800\udc10", "utf-8")
 
     def test_ascii_error(self):
         self.checkencodeerror(u"abc\xFF\xFF\xFFcde", "ascii", 3, 6)



More information about the Pypy-commit mailing list