Subject: bug#31149: 27.0.50; (gui-get-selection nil 'text/html) returns mis-decoded text

From: Eli Zaretskii <[email-masked]>
Date: Sun, 29 Sep 2019 12:31:58 +0300

> From: Lars Ingebrigtsen <[email-masked]>
> Date: Sun, 29 Sep 2019 10:44:48 +0200
> Cc: [email-masked]
> 
> >     if (html != None && sel_type == html) {
> > 	/* if the buffer contains UCS-2 (UTF-16), convert to
> > 	 * UTF-8.  Mozilla-based browsers do this for the
> > 	 * text/html target.
> > 	 */
> >     [...]
> >
> > and according to the subsequent code it's not even always the
> > same endianness.
> 
> I think it would make sense for us to do the same here.  It should be
> easy enough for us to detect that the string is utf-16, I think?

I think you want to use auto-coding-regexp-alist-lookup.

> The data has a BOM

Does it?  It doesn't have to, at least not in principle.