mirror of
https://git.telodendria.io/Telodendria/Cytoplasm.git
synced 2024-11-24 21:18:49 +03:00
Fix Unicode handling.
This commit is contained in:
parent
0b539a471d
commit
e557de8d9d
1 changed files with 2 additions and 20 deletions
22
src/Json.c
22
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 */
|
||||||
/*
|
StreamPutc(out, c);
|
||||||
* RFC 4627: "All Unicode characters may be placed
|
length++;
|
||||||
* 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);
|
|
||||||
length++;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
|
|
Loading…
Reference in a new issue