]> pd.if.org Git - pdclib.old/commitdiff
PDCLIB-2 PDCLIB-12 Correct surrogate behaviour of internal UTF-16 <-> UTF-32 helper...
authorOwen Shepherd <owen.shepherd@e43.eu>
Fri, 11 Jan 2013 18:17:56 +0000 (18:17 +0000)
committerOwen Shepherd <owen.shepherd@e43.eu>
Fri, 11 Jan 2013 18:17:56 +0000 (18:17 +0000)
internals/_PDCLIB_encoding.h

index f4b837fd6f631f948201759f33d7c1749d9eee4e..cec3089aa8e3ad01460485990255c5b950b33b3d 100644 (file)
@@ -75,12 +75,12 @@ static inline _PDCLIB_size_t _PDCLIB_c32rtoc16(
         return 1;
     } else {
         // Supplementary plane character
-        *out = 0xD800 | (*in & 0x3FF);
+        *out = 0xD800 | (*in >> 10);
         if(bufsize >= 2) {
-            out[1] = 0xDC00 | (*in >> 10);
+            out[1] = 0xDC00 | (*in & 0x3FF);
             return 2;
         } else {
-            ps->_Surrogate = 0xDC00 | (*in >> 10);
+            ps->_Surrogate = 0xDC00 | (*in & 0x3FF);
             return 1;
         }
     }