forked from lix-project/lix
22 lines
466 B
C++
22 lines
466 B
C++
#include <boost/io/ios_state.hpp>
|
|
#include <iomanip>
|
|
#include <iostream>
|
|
|
|
#include "escape-char.hh"
|
|
|
|
namespace nix {
|
|
|
|
std::ostream & operator<<(std::ostream & s, MaybeHexEscapedChar c)
|
|
{
|
|
boost::io::ios_flags_saver _ifs(s);
|
|
|
|
if (isprint(c.c)) {
|
|
s << static_cast<char>(c.c);
|
|
} else {
|
|
s << "\\x" << std::hex << std::setfill('0') << std::setw(2)
|
|
<< (static_cast<unsigned int>(c.c) & 0xff);
|
|
}
|
|
return s;
|
|
}
|
|
|
|
} // namespace nix
|