MCPcopy Create free account
hub / github.com/ElementsProject/elements / initJsonEscape

Function initJsonEscape

src/univalue/gen/gen.cpp:18–37  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16static std::string escapes[256];
17
18static void initJsonEscape()
19{
20 // Escape all lower control characters (some get overridden with smaller sequences below)
21 for (int ch=0x00; ch<0x20; ++ch) {
22 char tmpbuf[20];
23 snprintf(tmpbuf, sizeof(tmpbuf), "\\u%04x", ch);
24 escapes[ch] = std::string(tmpbuf);
25 }
26
27 escapes[(int)'"'] = "\\\"";
28 escapes[(int)'\\'] = "\\\\";
29 escapes[(int)'\b'] = "\\b";
30 escapes[(int)'\f'] = "\\f";
31 escapes[(int)'\n'] = "\\n";
32 escapes[(int)'\r'] = "\\r";
33 escapes[(int)'\t'] = "\\t";
34 escapes[(int)'\x7f'] = "\\u007f"; // U+007F DELETE
35
36 initEscapes = true;
37}
38
39static void outputEscape()
40{

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected