From 592d942b3be5e25619edbfe3d37a69bfa75810aa Mon Sep 17 00:00:00 2001 From: Thomas Jandecka Date: Wed, 14 Feb 2018 14:23:58 +0100 Subject: [PATCH] fix: byte shift when interpreting 32-bit utf-8 codepoints --- src/lib_json/json_writer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib_json/json_writer.cpp b/src/lib_json/json_writer.cpp index 5ffaa15..456424d 100644 --- a/src/lib_json/json_writer.cpp +++ b/src/lib_json/json_writer.cpp @@ -209,7 +209,7 @@ static unsigned int utf8ToCodepoint(const char*& s, const char* e) { if (e - s < 4) return REPLACEMENT_CHARACTER; - unsigned int calculated = ((firstByte & 0x07) << 24) + unsigned int calculated = ((firstByte & 0x07) << 18) | ((static_cast(s[1]) & 0x3F) << 12) | ((static_cast(s[2]) & 0x3F) << 6) | (static_cast(s[3]) & 0x3F);