Skip to content

Commit 313a0e4

Browse files
authored
Merge pull request open-source-parsers#743 from tjanc/tjanc/fix-utf8-codepoint
Incorrect byte shift when interpreting 32-bit utf-8 codepoints
2 parents 5b45aa5 + 592d942 commit 313a0e4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/lib_json/json_writer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ static unsigned int utf8ToCodepoint(const char*& s, const char* e) {
209209
if (e - s < 4)
210210
return REPLACEMENT_CHARACTER;
211211

212-
unsigned int calculated = ((firstByte & 0x07) << 24)
212+
unsigned int calculated = ((firstByte & 0x07) << 18)
213213
| ((static_cast<unsigned int>(s[1]) & 0x3F) << 12)
214214
| ((static_cast<unsigned int>(s[2]) & 0x3F) << 6)
215215
| (static_cast<unsigned int>(s[3]) & 0x3F);

0 commit comments

Comments
 (0)