From: Kenichi Handa Date: Wed, 7 Feb 2001 04:24:14 +0000 (+0000) Subject: (print_string): If we are going to print a unibyte X-Git-Tag: emacs-pretest-21.0.98~123 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=a76ef35dcef6e31260e547be723b806e55e34216;p=emacs.git (print_string): If we are going to print a unibyte string into a multibyte buffer, convert the string to multibyte by str_to_multibyte. --- diff --git a/src/print.c b/src/print.c index aca3116eb58..e9dd4ede83f 100644 --- a/src/print.c +++ b/src/print.c @@ -465,8 +465,23 @@ print_string (string, printcharfun) else if (EQ (printcharfun, Qt) ? ! NILP (buffer_defaults.enable_multibyte_characters) : ! NILP (current_buffer->enable_multibyte_characters)) - chars = multibyte_chars_in_text (XSTRING (string)->data, - STRING_BYTES (XSTRING (string))); + { + /* If unibyte string STRING contains 8-bit codes, we must + convert STRING to a multibyte string containing the same + character codes. */ + Lisp_Object newstr; + int bytes; + + chars = STRING_BYTES (XSTRING (string)); + bytes = parse_str_to_multibyte (XSTRING (string)->data, chars); + if (chars < bytes) + { + newstr = make_uninit_multibyte_string (chars, bytes); + bcopy (XSTRING (string)->data, XSTRING (newstr)->data, chars); + str_to_multibyte (XSTRING (newstr)->data, bytes, chars); + string = newstr; + } + } else chars = STRING_BYTES (XSTRING (string));