From 1fa8129c8f063a5508a63f2450c5c0184429e7ca Mon Sep 17 00:00:00 2001 From: Murphy Berzish Date: Fri, 25 Nov 2016 18:02:24 -0500 Subject: [PATCH] pretty-printing of general escape sequences for string literals --- src/ast/ast_smt2_pp.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/ast/ast_smt2_pp.cpp b/src/ast/ast_smt2_pp.cpp index 7e178b422..ed634069c 100644 --- a/src/ast/ast_smt2_pp.cpp +++ b/src/ast/ast_smt2_pp.cpp @@ -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]; } }