The current implementation rejects all input with bytes > 0x7E, which includes
all multibyte UTF-8 sequences. According to ECMA-404, Section 9, only double
quotation marks, backslashes, and characters 0x00 - 0x1F must be escaped
in JSON strings, so non-ascii bytes can just be passed without escaping.
This also mirrors what the decoder does above.
Of course this allows invalid UTF-8 characters to be encoded. Checks for this
could be added as well, but at least the decoder does not seem to do that.
And from what I can tell from a quick glance, the text output path does not
check that either.
Fixes: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/issues/1310