bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Lars Ingebrigtsen
Subject: bug#31149: 27.0.50; (gui-get-selection nil 'text/html) returns mis-decoded text
Date: Sun, 29 Sep 2019 10:44:48 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Stefan Monnier <monnier@IRO.UMontreal.CA> writes:

> (gui-get-selection nil 'text/html)
>
> returns utf-16 text when the primary selection is owned by Mozilla, but
> we decode it as latin-1 instead, so it looks like garbage.

This is still the case on the trunk:

#("ÿþM^@e^@r^@g^@e^@d^@" 0 14 (foreign-selection STRING charset iso-8859-1))

[...]

> I can't figure out if/where these kinds of things about the X11
> selection protocol is described, but at least in `xclip` they have
> a hack specifically for this case:
>
>     [...]
>     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?  The
data has a BOM and everything...

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





reply via email to

[Prev in Thread] Current Thread [Next in Thread]