1
0
mirror of https://github.com/nlohmann/json.git synced 2025-07-09 11:01:47 +03:00

added extensive Unicode tests

This commit is contained in:
Niels
2015-06-14 23:17:49 +02:00
parent 6fb829062c
commit 2e9a13bd88
5 changed files with 1112146 additions and 5 deletions

View File

@ -3513,8 +3513,11 @@ class basic_json
// calculate the codepoint from the given code points
std::size_t codepoint = codepoint1;
// check if codepoint1 is a high surrogate
if (codepoint1 >= 0xD800 and codepoint1 <= 0xDBFF)
{
// check if codepoint2 is a low surrogate
if (codepoint2 >= 0xDC00 and codepoint2 <= 0xDFFF)
{
codepoint =
@ -3533,7 +3536,7 @@ class basic_json
}
}
if (codepoint <= 0x7f)
if (codepoint < 0x80)
{
// 1-byte characters: 0xxxxxxx (ASCII)
result.append(1, static_cast<typename string_t::value_type>(codepoint));
@ -3800,6 +3803,7 @@ class basic_json
auto codepoint = std::strtoul(std::string(reinterpret_cast<typename string_t::const_pointer>(i + 1),
4).c_str(), nullptr, 16);
// check if codepoint is a high surrogate
if (codepoint >= 0xD800 and codepoint <= 0xDBFF)
{
// make sure there is a subsequent unicode