Subject: Re: bug#43632: Raw bytes printed as latin-1 in echo area and *Messages*

From: Eli Zaretskii <[email-masked]>
Date: Sat, 26 Sep 2020 20:27:23 +0300

> Date: Sat, 26 Sep 2020 19:57:21 +0300
> From: Eli Zaretskii <[email-masked]>
> Cc: [email-masked]
> 
> > From: Mattias Engdegård <[email-masked]>
> > Date: Sat, 26 Sep 2020 18:53:39 +0200
> > Cc: [email-masked]
> > 
> > --- a/lisp/simple.el
> > +++ b/lisp/simple.el
> > @@ -1797,6 +1797,7 @@ eval-expression
> >    (let ((print-length (unless no-truncate eval-expression-print-length))
> >          (print-level  (unless no-truncate eval-expression-print-level))
> >          (eval-expression-print-maximum-character char-print-limit)
> > +        (print-escape-nonascii t)
> >          (deactivate-mark))
> >      (let ((out (if insert-value (current-buffer) t)))
> >        (prog1
> 
> We are going to disregard user preferences regarding escapes?  For an
> obscure use case?  That doesn't make too much sense to me.

I'd rather risk something like the below instead:

diff --git a/src/print.c b/src/print.c
index 0ecc98f..5d878c9 100644
--- a/src/print.c
+++ b/src/print.c
@@ -1993,6 +1993,10 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
                     }
                   else if (print_escape_control_characters && c_iscntrl (c))
 		    octalout (c, SDATA (obj), i_byte, size_byte, printcharfun);
+		  else if (!multibyte
+			   && SINGLE_BYTE_CHAR_P (c)
+			   && !ASCII_CHAR_P (c))
+		    printchar (BYTE8_TO_CHAR (c), printcharfun);
                   else
                     printchar (c, printcharfun);
 		  need_nonhex = false;