mirror of
https://github.com/Z3Prover/z3
synced 2025-04-23 17:15:31 +00:00
zstring: fix encode rountrip for '\' as printable ASCII (#5120)
This fixes encode roundtripping for all printable ASCII characters. In particular, this now leaves a plain '\' untouched by the encoding logic, instead of converting it to escaped hex-digits. It also adds unit testing covering this specific zstring encoding property, in order to avoid future regressions.
This commit is contained in:
parent
119c5a995b
commit
b918f121ef
4 changed files with 28 additions and 1 deletions
|
@ -146,7 +146,7 @@ std::string zstring::encode() const {
|
|||
#define _flush() if (offset > 0) { buffer[offset] = 0; strm << buffer; offset = 0; }
|
||||
for (unsigned i = 0; i < m_buffer.size(); ++i) {
|
||||
unsigned ch = m_buffer[i];
|
||||
if (ch < 32 || ch >= 128 || ch == '\\') {
|
||||
if (ch < 32 || ch >= 128) {
|
||||
_flush();
|
||||
strm << "\\u{" << std::hex << ch << std::dec << "}";
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue