fix: byte shift when interpreting 32-bit utf-8 codepoints

This commit is contained in:
Thomas Jandecka 2018-02-14 14:23:58 +01:00
parent 5b45aa55ca
commit 592d942b3b

View File

@ -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<unsigned int>(s[1]) & 0x3F) << 12)
| ((static_cast<unsigned int>(s[2]) & 0x3F) << 6)
| (static_cast<unsigned int>(s[3]) & 0x3F);