Put quote marks around printed characters; also nicely print some escapes

This commit is contained in:
Eric Schmidt 2016-04-20 21:52:20 -06:00
parent f4ba8aaf19
commit d81594d7b7

View File

@ -149,9 +149,19 @@ std::string toString( bool value ) {
}
std::string toString( char value ) {
return value < ' '
? toString( static_cast<unsigned int>( value ) )
: Detail::makeString( value );
if ( value == '\r' )
return "'\\r'";
if ( value == '\l' )
return "'\\l'";
if ( value == '\n' )
return "'\\n'";
if ( value == '\t' )
return "'\\t'";
if ( '\0' <= value && value < ' ' )
return toString( static_cast<unsigned int>( value ) );
char chstr[] = "' '";
chstr[1] = value;
return chstr;
}
std::string toString( signed char value ) {