> From: Philipp Stephani <p.stephani2@gmail.com>
> Date: Tue, 23 Apr 2019 16:40:10 +0200
> Cc: Eli Zaretskii <eliz@gnu.org>, Sébastien Chapuis <sebastien@chapu.is>,
> yyoncho <yyoncho@gmail.com>, 31138@debbugs.gnu.org
>
> For starters, the module code in emacs-module.c (e.g.
> module_make_string) has essentially the same requirements. So we could
> at least move json_make_string, json_build_string, and json_encode
> into coding.[ch] (and rename them).
If we want to make this more general-purpose, we should time the code
with very long strings. It could be that beyond some length the UTF-8
verification, if it fails, will make the conversion slower, in which
case we probably should not take the shortcut beyond that length
limit.
Or we might document that non-UTF-8 strings will be slower to convert,
if that's acceptable.