]> mj.ucw.cz Git - libucw.git/commitdiff
JSON: Less strict checks when formatting strings
authorMartin Mares <mj@ucw.cz>
Fri, 17 Jul 2015 14:02:51 +0000 (16:02 +0200)
committerMartin Mares <mj@ucw.cz>
Fri, 17 Jul 2015 14:02:51 +0000 (16:02 +0200)
Invalid characters are translated to UNI_REPLACEMENT instead
of aborting the program.

ucw-json/format.c

index 8549f2ba114136b8803014c8bb9c82126681d378..227a26b548e7573c399f48b71d6701f15f77915f 100644 (file)
@@ -57,7 +57,7 @@ static void write_string(struct json_context *js, const char *p)
          else if (u < 0x110000)
            bprintf(fb, "\\u%04x\\u%04x", 0xd800 + ((u - 0x10000) >> 10), 0xdc00 + (u & 0x3ff));
          else
-           ASSERT(0);
+           bprintf(fb, "\\u%04x", UNI_REPLACEMENT);
        }
       else
        bput_utf8_32(fb, u);