diff --git a/src/json.c b/src/json.c index 928825e034..033fa27638 100644 --- a/src/json.c +++ b/src/json.c @@ -225,8 +225,17 @@ json_has_suffix (const char *string, const char *suffix) static Lisp_Object json_make_string (const char *data, ptrdiff_t size) { - return code_convert_string (make_specified_string (data, -1, size, false), - Qutf_8_unix, Qt, false, true, true); + ptrdiff_t nchars, multibyte_nbytes; + parse_str_as_multibyte ((const unsigned char *) data, size, + &nchars, &multibyte_nbytes); + + if (size == nchars) + /* Wasn't sure if the last arg should better be true here, but + it doesn't seem to affect the behavior or correctness, so far. */ + return make_specified_string (data, -1, size, false); + else + return code_convert_string (make_specified_string (data, -1, size, false), + Qutf_8_unix, Qt, false, true, true); } /* Create a multibyte Lisp string from the NUL-terminated UTF-8