|
|
@ -65,6 +65,21 @@ static int dump_indent(size_t flags, int depth, int space, json_dump_callback_t |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static const char *noutf8_iterate(const char *buffer, int32_t *codepoint) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
int32_t value; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!*buffer) |
|
|
|
|
|
|
|
return buffer; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
value = (unsigned char)buffer[0]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(codepoint) |
|
|
|
|
|
|
|
*codepoint = value; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return buffer + 1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static int dump_string(const char *str, json_dump_callback_t dump, void *data, size_t flags) |
|
|
|
static int dump_string(const char *str, json_dump_callback_t dump, void *data, size_t flags) |
|
|
|
{ |
|
|
|
{ |
|
|
|
const char *pos, *end; |
|
|
|
const char *pos, *end; |
|
|
@ -82,7 +97,10 @@ static int dump_string(const char *str, json_dump_callback_t dump, void *data, s |
|
|
|
|
|
|
|
|
|
|
|
while(*end) |
|
|
|
while(*end) |
|
|
|
{ |
|
|
|
{ |
|
|
|
end = utf8_iterate(pos, &codepoint); |
|
|
|
if(flags & JSON_NO_UTF8) |
|
|
|
|
|
|
|
end = noutf8_iterate(pos, &codepoint); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
end = utf8_iterate(pos, &codepoint); |
|
|
|
if(!end) |
|
|
|
if(!end) |
|
|
|
return -1; |
|
|
|
return -1; |
|
|
|
|
|
|
|
|
|
|
|