Subject: Re: bug#56344: 28.1; cannot copy-paste string with utf-8 letters (i.e.²): "Non-ASCII string must be encoded in advance"

From: Eli Zaretskii <[email-masked]>
Date: Sat, 02 Jul 2022 09:03:04 +0300

> From: "Dr. Arne Babenhauserheide" <[email-masked]>
> Date: Fri, 01 Jul 2022 23:53:02 +0200
> 
> I have a file that contains text with unicote:
> 
> - 12 ::
>   - Minerale finden (bis Distanz 10cm x 10 pro 3 Diff)
>   - Durchgang finden (10m x 10 pro 3 Diff)
>   - Steinwachstum (1 Liter x 10 pro 3 Diff, keine Edelsteine, sondern Grundgestein)
>   - Durchschlagend (Schaden von Geschoss oder Waffe + 1 pro 3 Diff für eine Handlung, Berührung)
> 
> 
> If I copy that (M-w) and try to paste it into a text field in the icecat
> browser (firefox derivative), I get the error message *in Emacs*:
> 
> Non-ASCII string must be encoded in advance: "- 12 ::
>   - Minerale finden (bis Distanz 10cm x 10 pro 3 Diff)
>   - Durchgang finden (10m x 10 pro 3 Diff)
>   - Steinwachstum (1 Liter x 10 pro 3 Diff, keine Edelsteine, sondern Grundgestein)
>   - Durchschlagend (Schaden von Geschoss oder Waffe + 1 pro 3 Diff f\374r eine Handlung, Ber\374hrung)"

Does this happen in "emacs -Q"?  If it does, can you run Emacs under
GDB, set a breakpoint in xselect.c here, on the line that calls
signal_error:

  else if (STRINGP (obj))
    {
      if (SCHARS (obj) < SBYTES (obj))
	/* OBJ is a multibyte string containing a non-ASCII char.  */
	signal_error ("Non-ASCII string must be encoded in advance", obj);

(it should be line 1731 of xselect.c)?  Then repeat the recipe, and
when the breakpoint breaks, produce a backtrace, like this:

  (gdb) thread apply all bt

and post it here.

Thanks.