Opened 9 years ago
Closed 8 years ago
#8632 closed Bugs (duplicate)
incorrect write_json()\read_json() for not latin1 charset.
| Reported by: | Owned by: | Sebastian Redl | |
|---|---|---|---|
| Milestone: | To Be Determined | Component: | property_tree |
| Version: | Boost 1.53.0 | Severity: | Problem |
| Keywords: | property_tree json_parser | Cc: |
Description
use MSVC compiler.
property_tree::ptree pt_1; // use symbol > 127
property_tree::write_json("file", pt_1);
property_tree::ptree pt_2;
property_tree::read_json("file", pt_2);
pt_1 != pt_2; !!!!!
for property_tree::wptree all correct.
in msvc char = signed int8.
typedef basic_string<char, char_traits<char>, allocator<char> >
string;
path: file boost\property_tree\detail\json_parser_write.hpp
template<class Ch> std::basic_string<Ch> create_escapes(const std::basic_string<Ch> &s)
typename std::basic_string<Ch>::const_iterator e = s.end();
while (b != e)
{
+ auto bb = static_cast<make_unsigned<Ch>::type>(*b);
// This assumes an ASCII superset. But so does everything in PTree.
// We escape everything outside ASCII, because this code can't
// handle high unicode characters.
- if (*b == 0x20 || *b == 0x21 || (*b >= 0x23 && *b <= 0x2E) ||
- (*b >= 0x30 && *b <= 0x5B) || (*b >= 0x5D && *b <= 0xFF))
+ if (bb == 0x20 || bb == 0x21 || (bb >= 0x23 && bb <= 0x2E) ||
+ (bb >= 0x30 && bb <= 0x5B) || (bb >= 0x5D && bb <= 0xFF))
Note:
See TracTickets
for help on using tickets.

Reported again (and fixed there) in bug 10820.