Subject: bug#51685: 29.0.50; Yanking from clipboard broken (Win10)

From: Eli Zaretskii <[email-masked]>
Date: Mon, 08 Nov 2021 15:38:12 +0200

> From: Lars Ingebrigtsen <[email-masked]>
> Date: Mon, 08 Nov 2021 12:27:43 +0100
> Cc: [email-masked]
> 
> >> 1) Start Emacs with emacs -Q (from a MinGW64 shell)
> >> 2) Open Windows Editor
> >> 3) Enter [email-masked] in Editor
> >> 4) Mark and Copy in Editor
> >> 5) Yank in scratch with C-y
> >
> > Does reverting 5e66c75e0 fix the issue?
> 
> I've reverted it now and will have to reexamine the problem before
> attempting a new fix.

Whatever you do, don't decode the selection text on MS-Windows.  It is
already decoded (see w32-get-clipboard-data), and
selection-coding-system is UTF-16 on MS-Windows, so decoding a decoded
string by that will not do anything useful ;-)

The existing code carefully side-steps the decoding by looking at the
foreign-selection property on the string, which the Windows code
doesn't set.  But your changes removed that test, and thus caused the
clipboard text to be decoded on Windows.