W3C home > Mailing lists > Public > whatwg@whatwg.org > February 2015

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

From: David Sheets <kosmo.zb@gmail.com>
Date: Fri, 13 Feb 2015 15:07:18 +0000
Message-ID: <CAAWM5TxYbHwHuH4kxArNZYzBLiZCe+JBHXvPmPeWYqohxoCL=A@mail.gmail.com>
To: Nils Dagsson Moskopp <nils@dieweltistgarnichtso.net>
Cc: whatwg <whatwg@whatwg.org>
On Fri, Feb 13, 2015 at 1:08 PM, Nils Dagsson Moskopp
<nils@dieweltistgarnichtso.net> wrote:
> David Sheets <kosmo.zb@gmail.com> writes:
>
>> On Fri, Feb 13, 2015 at 12:18 PM, James M. Greene
>> <james.m.greene@gmail.com> wrote:
>>> In this case, you can use Unicode escape values by preceding them with a
>>> slash:
>>>
>>>   .rarr:after { content: "\2192"; }
>>>
>>>
>>> This is specified in the CSS 2.1 spec:
>>> http://www.w3.org/TR/CSS2/syndata.html#characters
>>>
>>> Personally, I probably would've just started on StackOverflow with this
>>> question (e.g. [1]) but no harm done.
>>
>> Hi James!
>>
>> Sorry, I wasn't clear. The issue is not with putting Unicode values
>> into CSS. The issue is that I would like unicode values to be copied
>> and pasted as a specific ASCII fallback value.
>>
>> That is, I would like the equivalent of "a &rarr; b" to appear on a
>> page but, upon copying, "a -> b" to show up in the clipboard.
>>
>> I have a solution that works in Firefox 36 (described in original
>> mail). Chrome 40 does not behave similarly.
>>
>> I can see some arguments for Chrome's behavior along security lines. I
>> certainly can understand the utility of Firefox's behavior because I
>> am writing a documentation generation tool for a programming language
>> with right arrows represented as -> but would like to render them as
>> →.
>
> I would suggest to use OpenType ligatures for that. You could reasonably
> create a ligature font that renders any occurence of “->” as “→”.

This is a really brilliant solution that satisfies my use case
perfectly. I created the following (horrible) font that works as
expected.

<data:application/font-woff;base64,d09GRk9UVE8AAAXQAA0AAAAACAwAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABDRkYgAAABMAAAAY4AAAGdFwHC50ZGVE0AAALAA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DQz+EZnzNYMzICRRlYGNmgAFGBiQQkOaawnCAQZfBjtn4vzFDDNOs/6dR1CgAIRMAc0gMkAB4nGNgYGBmgGAZBkYGEHAB8hjBfBYGDSDNBqQZGZgYdBns/v8H8sH0/yv/j0DVAwEjGwOCQwzAUMxEiu5BCQAKpAk1AHicY2BkYGAA4hCza8vj+W2+MnCzMIDAReYDvHC6isGUuZRpFpDLwcAEEgUABpUIx3icY2BkYGCaxWDKEMPCAALMpQyMDKiAFQAsSwGxAAAAAgAAAAQAAI0EAAEnBAAAegPoAKAAAFAAAAUAAHichZDNSsNAFIXP9A8KItInmI1QIU0nKd1kaaGI4NLuWzJpAjUpyZTSrYgrn8VXcO3atWufwJ0LT6ZjQQSbYe797uHOmTsBcIpnCOy/Szw6Fuji3XEDHXw6buJcXDluoSvuHbdxJn58OtTf2ClaXVYP9lTNAj28Om7gBB+Om7jGl+MWeiJ33IYUT4471F8wQQmNOQxjDIkFdowxKqRUNPUKnl0SW2SsU9IUBXJynUss2ScRwodi7rPDcK0RYciVuN7k0OvTM2HMrf8FMCn13OhYLnYyrlKtTeV5ntxmJpXTIjfTolxqGfpK9lNj1tFwmFBNatWvEj/Xhh639pJ6wJV9SkApN5lZ6Zh4Y7UMG9yx0HG2Yf7vFRH3X8u9HmCEATvrrViNafVrzEgeriYHo0E4CFUwPjbkjFrJf5PZuSS9a3ff5nomzHRZZUUulQp8pZQ8YvgNzG5wnAAAAHicY2BmAIP/DQzGDFgAACgUAbYA>

The browser inconsistency in the original case still stands, though.
Is there a spec covering copy and paste?

David

> --
> Nils Dagsson Moskopp // erlehmann
> <http://dieweltistgarnichtso.net>
Received on Friday, 13 February 2015 15:07:46 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 17:00:27 UTC