MCPcopy Create free account
hub / github.com/cinience/RedisStudio / Chrtos

Method Chrtos

RedisStudio/Base/String.cpp:47–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45}
46
47std::string String::Chrtos( char byte)
48{
49 std::string str;
50 size_t len = 0;
51 char buf[24] = {0};
52 size_t size = 23;
53 switch(byte) {
54 case '\\':
55 case '"':
56 len = _snprintf(buf,size,"\\%c",byte);
57 break;
58 case '\n': len = _snprintf(buf,size,"\\n"); break;
59 case '\r': len = _snprintf(buf,size,"\\r"); break;
60 case '\t': len = _snprintf(buf,size,"\\t"); break;
61 case '\a': len = _snprintf(buf,size,"\\a"); break;
62 case '\b': len = _snprintf(buf,size,"\\b"); break;
63 default:
64 if (byte >= 33 && byte <=93)
65 len = _snprintf(buf,size,"%c",byte);
66 else
67 len = _snprintf(buf,size,"\\x%02x",(unsigned char)byte);
68 break;
69 }
70 str.assign(buf, len);
71 return str;
72}
73
74} // namespace Base

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected