MCPcopy Create free account
hub / github.com/aardappel/treesheets / EscapeAndQuote

Function EscapeAndQuote

lobster/src/vmdata.cpp:28–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26char HexChar(char i) { return i + (i < 10 ? '0' : 'A' - 10); }
27
28void EscapeAndQuote(string_view s, ostringstream &ss) {
29 ss << '\"';
30 for (auto c : s) switch(c) {
31 case '\n': ss << "\\n"; break;
32 case '\t': ss << "\\t"; break;
33 case '\r': ss << "\\r"; break;
34 case '\\': ss << "\\\\"; break;
35 case '\"': ss << "\\\""; break;
36 case '\'': ss << "\\\'"; break;
37 default:
38 if (c >= ' ' && c <= '~') ss << c;
39 else ss << "\\x" << HexChar(((uchar)c) >> 4) << HexChar(c & 0xF);
40 break;
41 }
42 ss << "\"";
43}
44
45void LString::DeleteSelf(VM &vm) { vm.pool.dealloc(this, sizeof(LString) + len + 1); }
46

Callers 3

ToStringMethod · 0.85
ToNativeFunction · 0.85
DisAsmInsFunction · 0.85

Calls 1

HexCharFunction · 0.85

Tested by

no test coverage detected