Skip to content

Commit 784b59d

Browse files
author
Scott MacVicar
committed
Fix bug #46944 - UTF-8 characters outside the BMP aren't encoded correctly.
1 parent b301ee4 commit 784b59d

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

ext/json/utf8_decode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ int utf8_decode_next(json_utf8_decode *utf8) /* {{{ */
159159
/*
160160
Three continuation (65536 to 1114111)
161161
*/
162-
if ((c & 0xF1) == 0xF0) {
162+
if ((c & 0xF8) == 0xF0) {
163163
int c1 = cont(utf8);
164164
int c2 = cont(utf8);
165165
int c3 = cont(utf8);

ext/json/utf8_to_utf16.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ int utf8_to_utf16(unsigned short w[], char p[], int length) /* {{{ */
4545
w[the_index] = (unsigned short)c;
4646
the_index += 1;
4747
} else {
48-
c &= 0xFFFF;
48+
c -= 0x10000;
4949
w[the_index] = (unsigned short)(0xD800 | (c >> 10));
5050
the_index += 1;
5151
w[the_index] = (unsigned short)(0xDC00 | (c & 0x3FF));

0 commit comments

Comments
 (0)