Fix bug #46944 - UTF-8 characters outside the BMP aren't encoded correctly.

This commit is contained in:
Scott MacVicar 2009-01-02 03:01:53 +00:00
parent b301ee4c5e
commit 784b59d016
2 changed files with 2 additions and 2 deletions

View 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);

View 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));