mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-05-29 07:25:55 +02:00
Save the flags of the stream
Changing the stream to `std::hex` mode should only affect the current character; otherwise printing some msgpack with a list like this: `[123, "string\\u0003", 123]` (123 decimal) ends up printing `[123, "string\\u0003", 7b]`, as `std::hex` is sticky.
This commit is contained in:
parent
1df97bc37b
commit
03b770fdf2
@ -802,7 +802,9 @@ inline std::ostream& operator<< (std::ostream& s, const msgpack::object& o)
|
|||||||
default: {
|
default: {
|
||||||
unsigned int code = static_cast<unsigned int>(c);
|
unsigned int code = static_cast<unsigned int>(c);
|
||||||
if (code < 0x20 || code == 0x7f) {
|
if (code < 0x20 || code == 0x7f) {
|
||||||
|
std::ios::fmtflags flags(s.flags());
|
||||||
s << "\\u" << std::hex << std::setw(4) << std::setfill('0') << (code & 0xff);
|
s << "\\u" << std::hex << std::setw(4) << std::setfill('0') << (code & 0xff);
|
||||||
|
s.flags(flags);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
s << c;
|
s << c;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user