Subject: bug#27270: display-raw-bytes-as-hex generates ambiguous output for Emacs strings

From: Paul Eggert <[email-masked]>
Date: Thu, 8 Jun 2017 08:56:31 -0700

On 06/07/2017 06:07 PM, [email-masked] wrote:
> display-raw-bytes-as-hex does affect the result display for me (of
> course, since the result goes into the buffer), doesn't it for you?

Sorry, it didn't when I tried it earlier, but apparently I messed up. 
Yes, it does affect the display.

But this means the problem is even worse than I thought. If I evaluate 
this in *scratch* in a terminal session running emacs -nw:

(setq display-raw-bytes-as-hex t) C-j
(format "%c%c" ?\u0090 ?5) C-j

Emacs displays this:

"\x905"

which is the wrong string visually. And if I cut this string out of the 
terminal window and paste it into another terminal window running Emacs, 
I'll get "अ" (a string containing the single character U+0905 DEVANAGARI 
LETTER A), which is indeed the wrong string. The string should be 
displayed unambiguously, either like this:

"\x80\ 5"

or via some other means.

The bottom line is that the visual display of buffers and strings should 
continue to be unambiguous even when display-raw-bytes-as-hex is t.