diff --git a/src/jansson-2.6/src/dump.c b/src/jansson-2.6/src/dump.c index 3b19c73b..452f166b 100644 --- a/src/jansson-2.6/src/dump.c +++ b/src/jansson-2.6/src/dump.c @@ -65,6 +65,21 @@ static int dump_indent(size_t flags, int depth, int space, json_dump_callback_t 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) { 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) { - end = utf8_iterate(pos, &codepoint); + if(flags & JSON_NO_UTF8) + end = noutf8_iterate(pos, &codepoint); + else + end = utf8_iterate(pos, &codepoint); if(!end) return -1; diff --git a/src/jansson-2.6/src/jansson.h b/src/jansson-2.6/src/jansson.h index 3f67edf1..8cc2760e 100644 --- a/src/jansson-2.6/src/jansson.h +++ b/src/jansson-2.6/src/jansson.h @@ -260,6 +260,7 @@ json_t *json_load_callback(json_load_callback_t callback, void *data, size_t fla #define JSON_PRESERVE_ORDER 0x100 #define JSON_ENCODE_ANY 0x200 #define JSON_ESCAPE_SLASH 0x400 +#define JSON_NO_UTF8 0x800 typedef int (*json_dump_callback_t)(const char *buffer, size_t size, void *data);