| 16 | static std::string escapes[256]; |
| 17 | |
| 18 | static 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 | |
| 39 | static void outputEscape() |
| 40 | { |