# HG changeset patch # User Kenichi Handa # Date 981519854 0 # Node ID 0c203af33b2d2f0362446fb091eb21c0dbf3858f # Parent 9d09efb7f38245e087d094bf9b61dd77060e35cb (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 -r 9d09efb7f382 -r 0c203af33b2d src/print.c --- a/src/print.c Wed Feb 07 04:23:59 2001 +0000 +++ b/src/print.c Wed Feb 07 04:24:14 2001 +0000 @@ -465,8 +465,23 @@ 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));