#include <algorithm>
#include <list>
#include <stdexcept>
+#include <cctype>
#include "utils.h"
using namespace std;
result += "\\\\";
else if(static_cast<unsigned char>(*i)<' ' || (escape_8bit && (*i&0x80)))
{
- char buf[4] = {'\\', '0'+((*i>>6)&3), '0'+((*i>>3)&7), '0'+(*i&7)};
+ char buf[4] = { '\\', 0 };
+ for(unsigned j=0; j<3; ++j)
+ buf[1+j] = '0'+((static_cast<unsigned char>(*i)>>(6-j*3))&7);
result.append(buf, 4);
}
else