forked from Telodendria/Cytoplasm
Fix Unicode handling.
This commit is contained in:
parent
0b539a471d
commit
e557de8d9d
1 changed files with 2 additions and 20 deletions
18
src/Json.c
18
src/Json.c
|
@ -376,26 +376,8 @@ JsonEncodeString(const char *str, Stream * out)
|
||||||
length += 2;
|
length += 2;
|
||||||
break;
|
break;
|
||||||
default: /* Assume UTF-8 input */
|
default: /* Assume UTF-8 input */
|
||||||
/*
|
|
||||||
* RFC 4627: "All Unicode characters may be placed
|
|
||||||
* within the quotation marks except for the characters
|
|
||||||
* that must be escaped: quotation mark, reverse solidus,
|
|
||||||
* and the control characters (U+0000 through U+001F)."
|
|
||||||
*
|
|
||||||
* This technically covers the above cases for backspace,
|
|
||||||
* tab, newline, feed, and carriage return characters,
|
|
||||||
* but we can save bytes if we encode those as their
|
|
||||||
* more human-readable representation.
|
|
||||||
*/
|
|
||||||
if (c <= 0x001F)
|
|
||||||
{
|
|
||||||
length += StreamPrintf(out, "\\u%04x", c);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
StreamPutc(out, c);
|
StreamPutc(out, c);
|
||||||
length++;
|
length++;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
|
|
Loading…
Reference in a new issue