Fix Unicode handling.

This commit is contained in:
Jordan Bancino 2023-06-21 02:49:58 +00:00
parent 0b539a471d
commit e557de8d9d

View file

@ -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++;