diff --git a/include/rapidjson/encodings.h b/include/rapidjson/encodings.h index edfc990..baa7c2b 100644 --- a/include/rapidjson/encodings.h +++ b/include/rapidjson/encodings.h @@ -154,7 +154,11 @@ struct UTF8 { } unsigned char type = GetRange(static_cast(c)); - *codepoint = (0xFF >> type) & static_cast(c); + if (type >= 32) { + *codepoint = 0; + } else { + *codepoint = (0xFF >> type) & static_cast(c); + } bool result = true; switch (type) { case 2: TAIL(); return result;