mirror of https://github.com/akheron/jansson
Merge pull request #255 from gonzzor/snprintf_dump.c
Improve usage of snprintf in dump.c
This commit is contained in:
commit
4876bda857
|
@ -134,7 +134,7 @@ static int dump_string(const char *str, size_t len, json_dump_callback_t dump, v
|
||||||
/* codepoint is in BMP */
|
/* codepoint is in BMP */
|
||||||
if(codepoint < 0x10000)
|
if(codepoint < 0x10000)
|
||||||
{
|
{
|
||||||
snprintf(seq, 13, "\\u%04X", codepoint);
|
snprintf(seq, sizeof(seq), "\\u%04X", (unsigned int)codepoint);
|
||||||
length = 6;
|
length = 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ static int dump_string(const char *str, size_t len, json_dump_callback_t dump, v
|
||||||
first = 0xD800 | ((codepoint & 0xffc00) >> 10);
|
first = 0xD800 | ((codepoint & 0xffc00) >> 10);
|
||||||
last = 0xDC00 | (codepoint & 0x003ff);
|
last = 0xDC00 | (codepoint & 0x003ff);
|
||||||
|
|
||||||
snprintf(seq, 13, "\\u%04X\\u%04X", first, last);
|
snprintf(seq, sizeof(seq), "\\u%04X\\u%04X", (unsigned int)first, (unsigned int)last);
|
||||||
length = 12;
|
length = 12;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue