1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-12-18 15:00:26 +00:00

hprint:: added as_nice_cstring

This commit is contained in:
Zeno Rogue 2021-05-23 15:46:07 +02:00
parent 0f767e16b6
commit 087c815372

View File

@ -436,6 +436,19 @@ EX string as_cstring(string o) {
return s; return s;
} }
EX string as_nice_cstring(string o) {
string s = "\"";
for(char c: o)
if(c >= 32 && c < 126)
s += c;
else if(c == 10)
s += "\\n";
else
s += format("\\x%02x", (unsigned char) c);
s += "\"";
return s;
}
#if HDR #if HDR
#if ISANDROID #if ISANDROID
#define DEBB(r,x) #define DEBB(r,x)