mirror of
https://github.com/nlohmann/json.git
synced 2025-07-28 12:02:00 +03:00
🐛 fix for #656
A complete rewrite of the string escape function. It now provides codepoint-to-\uxxxx escaping. Invalid UTF-8 byte sequences are not escaped, but copied as-is. I haven’t spent much time optimizing the code - but the library now agrees with Python on every single Unicode character’s escaping (see file test/data/json_nlohmann_tests/all_unicode_ascii.json). Other minor changes: replaced "size_t" by "std::size_t"
This commit is contained in:
@ -98,7 +98,9 @@ TEST_CASE("convenience functions")
|
||||
check_escaped("\x1d", "\\u001d");
|
||||
check_escaped("\x1e", "\\u001e");
|
||||
check_escaped("\x1f", "\\u001f");
|
||||
check_escaped("\xA9", "\xA9");
|
||||
check_escaped("\xA9", "\\u00a9", true);
|
||||
|
||||
// invalid UTF-8 characters
|
||||
check_escaped("ä\xA9ü", "ä\xA9ü");
|
||||
check_escaped("ä\xA9ü", "\\u00e4\xA9\\u00fc", true);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user