Fix Unicode handling.

This commit is contained in:
Jordan Bancino 2023-06-21 02:49:58 +00:00
parent 539fde773f
commit 3054a80906
2 changed files with 3 additions and 21 deletions

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

View file

@ -45,7 +45,7 @@ Milestone: v0.4.0
use the default. This will make debugging a lot easier. use the default. This will make debugging a lot easier.
[ ] Make sure admin registration token is printed to log, not stdout. [ ] Make sure admin registration token is printed to log, not stdout.
Unless they are the same, of course. Unless they are the same, of course.
[ ] Fix Json UTF-8 handling. [x] Fix Json UTF-8 handling.
Milestone: v0.5.0 Milestone: v0.5.0
----------------- -----------------