Subject: Re: bug#43598: replace-in-string: finishing touches

From: Eli Zaretskii <[email-masked]>
Date: Fri, 25 Sep 2020 12:21:45 +0300

> From: Lars Ingebrigtsen <[email-masked]>
> Date: Fri, 25 Sep 2020 01:18:13 +0200
> Cc: [email-masked]
> 
> So: "a\377ø" is a multibyte string with five bytes (the "raw byte" is in
> the private plane).
> 
> "a\377a" is a unibyte string with three bytes.
> 
> So searching for "\377" (one-byte unibyte string) and (make-string 1
> 255) (two-byte multibyte string) should be well-defined in either
> combination here?
> 
> "\377" is in both "a\377ø" and "a\377a".
> 
> (make-string 1 255) is in neither "a\377ø", nor "a\377a".
> 
> And:
> 
> (eq (elt (make-string 1 255) 0) (elt "\377" 0))
> => t

Would it help to always convert the first argument of
replace-in-string to a multibyte string, before replacing?