Changed " to ' in logging and removed \" chars

This commit is contained in:
Alex Zolotarev 2011-09-25 16:32:58 +03:00 committed by Alex Zolotarev
parent aedeb045ff
commit 8767f759fb

View file

@ -3,25 +3,20 @@
string debug_print(string const & t)
{
string res;
res.push_back('\"');
res.push_back('\'');
for (string::const_iterator it = t.begin(); it != t.end(); ++it)
{
static char const toHex[] = "0123456789abcdef";
unsigned char const c = static_cast<unsigned char>(*it);
if (c >= ' ' && c <= '~' && c != '\\' && c != '"')
if (c >= ' ' && c <= '~')
res.push_back(*it);
else
{
res.push_back('\\');
if (c == '\\' || c == '"')
res.push_back(c);
else
{
res.push_back(toHex[c >> 4]);
res.push_back(toHex[c & 0xf]);
}
res.push_back(toHex[c >> 4]);
res.push_back(toHex[c & 0xf]);
}
}
res.push_back('\"');
res.push_back('\'');
return res;
}