hprint:: added as_nice_cstring

This commit is contained in:
Zeno Rogue
2021-05-23 16:00:50 +02:00
parent 0f767e16b6
commit 087c815372
+13
View File
@@ -436,6 +436,19 @@ EX string as_cstring(string o) {
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 ISANDROID
#define DEBB(r,x)