]> granicus.if.org Git - php/commitdiff
Fix bug #46944 - UTF-8 characters outside the BMP aren't encoded correctly.
authorScott MacVicar <scottmac@php.net>
Fri, 2 Jan 2009 03:01:53 +0000 (03:01 +0000)
committerScott MacVicar <scottmac@php.net>
Fri, 2 Jan 2009 03:01:53 +0000 (03:01 +0000)
ext/json/utf8_decode.c
ext/json/utf8_to_utf16.c

index bb4065c700bb8ee266f1502c102f685e46e8ad4d..2c0bd8842e0b1f124c618500b07de8ce80f736ae 100644 (file)
@@ -159,7 +159,7 @@ int utf8_decode_next(json_utf8_decode *utf8) /* {{{ */
        /*
           Three continuation (65536 to 1114111)
           */
-       if ((c & 0xF1) == 0xF0) {
+       if ((c & 0xF8) == 0xF0) {
                int c1 = cont(utf8);
                int c2 = cont(utf8);
                int c3 = cont(utf8);
index cb6bbec7ffb2c563ac88147389627e0193999b9d..a2ec582789786ce7de2f487c6a63c5b0f914a896 100644 (file)
@@ -45,7 +45,7 @@ int utf8_to_utf16(unsigned short w[], char p[], int length)  /* {{{ */
                        w[the_index] = (unsigned short)c;
                        the_index += 1;
                } else {
-                       c &= 0xFFFF;
+                       c -= 0x10000;
                        w[the_index] = (unsigned short)(0xD800 | (c >> 10));
                        the_index += 1;
                        w[the_index] = (unsigned short)(0xDC00 | (c & 0x3FF));