Commit c26556bd authored by Eli Zaretskii's avatar Eli Zaretskii

Fix and speed up en/decoding of UTF-8 strings

* src/coding.c (get_char_bytes, encode_string_utf_8)
(decode_string_utf_8): Fix commentary.
(encode_string_utf_8): Return the original ASCII string only
if NOCOPY is non-zero.
(decode_string_utf_8): Accept 2 additional arguments STR and
STR_LEN, which allow to pass the input text as a C string.
(make_string_from_utf8): Delegate the job to decode_string_utf_8.
* src/coding.h: Update the prototype of decode_string_utf_8.
* src/json.c (json_encode): Call encode_string_utf_8.
parent 6d4d00c6
Pipeline #4142 failed with stage
in 60 minutes and 8 seconds
This diff is collapsed.
......@@ -691,7 +691,8 @@ extern Lisp_Object code_convert_string_norecord (Lisp_Object, Lisp_Object,
extern Lisp_Object encode_string_utf_8 (Lisp_Object, Lisp_Object, bool,
Lisp_Object, Lisp_Object);
extern Lisp_Object decode_string_utf_8 (Lisp_Object, Lisp_Object, bool,
extern Lisp_Object decode_string_utf_8 (Lisp_Object, const char *, ptrdiff_t,
Lisp_Object, bool,
Lisp_Object, Lisp_Object);
extern Lisp_Object encode_file_name (Lisp_Object);
extern Lisp_Object decode_file_name (Lisp_Object);
......@@ -228,7 +228,7 @@ json_encode (Lisp_Object string)
/* FIXME: Raise an error if STRING is not a scalar value
sequence. */
return code_convert_string (string, Qutf_8_unix, Qt, true, true, true);
return encode_string_utf_8 (string, Qnil, false, Qt, Qt);
static AVOID
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment