Skip to content

Commit

Permalink
merged #111
Browse files Browse the repository at this point in the history
  • Loading branch information
nlohmann committed Aug 14, 2015
1 parent 6f2da1a commit b58a93b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ I deeply appreciate the help of the following people.
- [易思龙](https://github.com/likebeta) implemented a conversion from anonymous enums.
- [kepkin](https://github.com/kepkin) patiently pushed forward the support for Microsoft Visual studio.
- [gregmarr](https://github.com/gregmarr) simplified the implementation of reverse iterators.
- [Caio Luppi](https://github.com/caiovlp) fixed a bug in the Unicode handling.

Thanks a lot for helping out!

Expand Down
2 changes: 2 additions & 0 deletions src/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4692,6 +4692,8 @@ class basic_json
// print character c as \uxxxx
sprintf(&result[pos + 1], "u%04x", int(c));
pos += 6;
// overwrite trailing null character
result[pos] = '\\';
}
else
{
Expand Down
2 changes: 2 additions & 0 deletions src/json.hpp.re2c
Original file line number Diff line number Diff line change
Expand Up @@ -4692,6 +4692,8 @@ class basic_json
// print character c as \uxxxx
sprintf(&result[pos + 1], "u%04x", int(c));
pos += 6;
// overwrite trailing null character
result[pos] = '\\';
}
else
{
Expand Down
8 changes: 8 additions & 0 deletions test/unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10194,4 +10194,12 @@ TEST_CASE("regression tests")
// hexadecimal "a"
CHECK(j.dump() == "{\"binary string\":\"\\u0000asdf\\n\",\"int64\":10}");
}

SECTION("issue #111 - subsequent unicode chars")
{
std::string bytes{0x7, 0x7};
json j;
j["string"] = bytes;
CHECK(j["string"] == "\u0007\u0007");
}
}

0 comments on commit b58a93b

Please sign in to comment.