From 784b59d016cdff59d0a477edb693cd5702b1d814 Mon Sep 17 00:00:00 2001 From: Scott MacVicar Date: Fri, 2 Jan 2009 03:01:53 +0000 Subject: [PATCH] Fix bug #46944 - UTF-8 characters outside the BMP aren't encoded correctly. --- ext/json/utf8_decode.c | 2 +- ext/json/utf8_to_utf16.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/json/utf8_decode.c b/ext/json/utf8_decode.c index bb4065c700..2c0bd8842e 100644 --- a/ext/json/utf8_decode.c +++ b/ext/json/utf8_decode.c @@ -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); diff --git a/ext/json/utf8_to_utf16.c b/ext/json/utf8_to_utf16.c index cb6bbec7ff..a2ec582789 100644 --- a/ext/json/utf8_to_utf16.c +++ b/ext/json/utf8_to_utf16.c @@ -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)); -- 2.40.0