From c3e273f0f9129ca87a808f1ccec348c16393cf9b Mon Sep 17 00:00:00 2001 From: "Lukasz A.J. Wrona" Date: Tue, 8 Aug 2017 13:00:04 +0100 Subject: [PATCH] Escape backslash, \t, \f and \b in generated tests --- src/util/unicode.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/util/unicode.cpp b/src/util/unicode.cpp index 6ea0e3cc364..6e0c483ec08 100644 --- a/src/util/unicode.cpp +++ b/src/util/unicode.cpp @@ -298,10 +298,16 @@ std::string utf16_little_endian_to_java(const std::wstring &in) result << "\\n"; else if(ch=='\r') result << "\\r"; + else if(ch=='\f') + result << "\\f"; + else if(ch=='\b') + result << "\\b"; + else if(ch=='\t') + result << "\\t"; else if(ch<=255 && isprint(ch, loc)) { const auto uch=static_cast(ch); - if(uch=='"') + if(uch=='"' || uch=='\\') result << '\\'; result << uch; }