tool_writeout_json: fix encoding of control characters

Control characters without a special escape sequence e.g. %00 or %06
were being encoded as "u0006" instead of "\u0006".

Ref: https://github.com/curl/trurl/pull/214#discussion_r1257487858
Closes #11414
This commit is contained in:
Emanuele Torre 2023-07-09 16:45:39 +02:00 committed by Daniel Stenberg
parent 15b131352b
commit 8484ad09da
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

View File

@ -62,7 +62,7 @@ void jsonWriteString(FILE *stream, const char *in, bool lowercase)
break;
default:
if(*i < 32) {
fprintf(stream, "u%04x", *i);
fprintf(stream, "\\u%04x", *i);
}
else {
char out = *i;