Re: [whatwg] Unicode -> ASCII copy/paste fallback

On Fri, Feb 13, 2015 at 3:02 PM, Glenn Maynard <glenn@zewt.org> wrote:
> On Fri, Feb 13, 2015 at 5:45 AM, David Sheets <kosmo.zb@gmail.com> wrote:
>>
>> Hello,
>>
>> I have a page with
>>
>> a <span class="rarr"><span>-&gt;</span></span> b
>>
>> and style
>>
>> .rarr span { overflow: hidden; height: 0; width: 0; display: inline-block;
>> }
>> .rarr::after { content: "→"; }
>>
>> (That's RIGHTWARDS ARROW x2192.)
>>
>> In Firefox 36, this copies and pastes like "a -> b" which is the
>> desired behavior. In Chrome 40, this copies and pastes like "a  b".
>>
>> Is my desired behavior (to show unicode but copy an ASCII
>> representation) generally possible? Are there specs somewhere about
>> copy/paste behavior? I looked in <https://html.spec.whatwg.org/> but
>> found nothing relevant.
>
>
> Copying ASCII isn't desirable.  It should copy the Unicode string "a → b".
> After all, that's what gets copied if you had done "<span>a → b</span>" in
> the first place.
>
> (Chrome's issue isn't related to Unicode.  It just doesn't know how to
> select text that's inside CSS content, so it isn't included in the copy.)

The only relation this issue has to Unicode is a use case for
alternate copy/paste behavior.

Judging from the replies to my original inquiry, either Firefox or
Chrome is doing something unexpected or both are behaving unexpectedly
(and should put the unicode arrow on the clipboard).

I'm not sure if all use cases for my original trick can be covered by
using OpenType ligatures (thanks, Nils!) or if there are other
'alternative clipboard behavior' applications. Certainly, the most
consistent behavior would be for both Chrome and Firefox (and other
browsers that I haven't/don't care to test) to put the CSS content on
the clipboard and ignore hidden content.

I suppose currently Chrome is preventing copying hidden content but
Firefox is not and neither picks up the CSS content.

David

Received on Friday, 13 February 2015 15:15:33 UTC