15 static bool initEscapes;
16 static std::string escapes[256];
18 static void initJsonEscape()
21 for (
int ch=0x00; ch<0x20; ++ch) {
23 snprintf(tmpbuf,
sizeof(tmpbuf),
"\\u%04x", ch);
24 escapes[ch] = std::string(tmpbuf);
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";
39 static void outputEscape()
41 printf(
"// Automatically generated file. Do not modify.\n" 42 "#ifndef BITCOIN_UNIVALUE_UNIVALUE_ESCAPES_H\n" 43 "#define BITCOIN_UNIVALUE_UNIVALUE_ESCAPES_H\n" 44 "static const char *escapes[256] = {\n");
46 for (
unsigned int i = 0; i < 256; i++) {
47 if (escapes[i].empty()) {
53 for (si = 0; si < escapes[i].size(); si++) {
54 char ch = escapes[i][si];
63 printf(
"%c", escapes[i][si]);
73 "#endif // BITCOIN_UNIVALUE_UNIVALUE_ESCAPES_H\n");
76 int main (
int argc,
char *argv[])
int main(int argc, char *argv[])