3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-23 17:15:31 +00:00

pretty-printing of general escape sequences for string literals

This commit is contained in:
Murphy Berzish 2016-11-25 18:02:24 -05:00
parent 889b6be2c3
commit 1fa8129c8f

View file

@ -341,8 +341,14 @@ format * smt2_pp_environment::pp_str_literal(app * t) {
} else if (c == '\\') {
buf << "\\" << "\\";
} else {
// TODO general hex escape
NOT_IMPLEMENTED_YET();
// general hex escape
buf << "\\x";
unsigned int cVal = (unsigned int)c;
const char convtable[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
unsigned int highPart = cVal / 16;
unsigned int lowPart = cVal % 16;
SASSERT(highPart < 16); SASSERT(lowPart < 16);
buf << convtable[highPart] << convtable[lowPart];
}
}