17 static bool initEscapes;
18 static std::string escapes[256];
20 static void initJsonEscape()
23 for (
int ch=0x00; ch<0x20; ++ch) {
25 snprintf(tmpbuf,
sizeof(tmpbuf),
"\\u%04x", ch);
26 escapes[ch] = std::string(tmpbuf);
29 escapes[(int)
'"'] =
"\\\"";
30 escapes[(int)
'\\'] =
"\\\\";
31 escapes[(int)
'\b'] =
"\\b";
32 escapes[(int)
'\f'] =
"\\f";
33 escapes[(int)
'\n'] =
"\\n";
34 escapes[(int)
'\r'] =
"\\r";
35 escapes[(int)
'\t'] =
"\\t";
36 escapes[(int)
'\x7f'] =
"\\u007f";
41 static void outputEscape()
43 printf(
"// Automatically generated file. Do not modify.\n"
44 "#ifndef BITCOIN_UNIVALUE_UNIVALUE_ESCAPES_H\n"
45 "#define BITCOIN_UNIVALUE_UNIVALUE_ESCAPES_H\n"
46 "static const char *escapes[256] = {\n");
48 for (
unsigned int i = 0; i < 256; i++) {
49 if (escapes[i].empty()) {
55 for (si = 0; si < escapes[i].size(); si++) {
56 char ch = escapes[i][si];
65 printf(
"%c", escapes[i][si]);
75 "#endif // BITCOIN_UNIVALUE_UNIVALUE_ESCAPES_H\n");
78 int main (
int argc,
char *argv[])