diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 55009015b..d53e7d8c9 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -3785,6 +3785,7 @@ void Tokenizer::printDebugOutput() const static std::string toxml(const std::string &str) { std::ostringstream xml; + const bool isstring(str[0] == '\"'); for (std::size_t i = 0U; i < str.length(); i++) { char c = str[i]; switch (c) { @@ -3800,8 +3801,14 @@ static std::string toxml(const std::string &str) case '\"': xml << """; break; + case '\0': + xml << "\\0"; + break; default: - xml << c; + if (!isstring || (c >= ' ' && c <= 'z')) + xml << c; + else + xml << 'x'; break; } }