crossroads

Git mirror of https://crossroads.e-tunity.com/
git clone git://git.finwo.net/app/crossroads
Log | Files | Refs | LICENSE

printable.cc (437B)


      1 #include "netbuffer"
      2 
      3 string Netbuffer::printable (char ch) const {
      4     ostringstream o;
      5     
      6     if (isprint(ch) && ch != '\\') {
      7 	o << ch;
      8 	return (o.str());
      9     } else if (ch == '\n')
     10 	return ("\\n");
     11     else if (ch == '\r')
     12 	return ("\\r");
     13     else if (ch == '\t')
     14 	return ("\\t");
     15     else {
     16 	char buf[10];
     17 	sprintf (buf, "%3.3o", ch & 0xff);
     18 	o << "\\" << buf;
     19 	return (o.str());
     20     }
     21 
     22     // Avoid warnings
     23     return (".");
     24 }