3

I don't understand the following part from this solution:

\peek_charcode:NTF ^^f0

What does the '^^f0' mean? Where does it come from? I looked into interface3.pdf and couldn't find anything.

The unicode replacement works nicely for 1f1e9-1f1ea (🇩🇪, german flag), 1f468-1f3ff (👨🏿, emoji skin color variation) and 1f3f3-1f308 (🏴☠, pirate flag). But not on 1f3f4-2620 (🏳🌈, rainbow flag).

I guess it is connected to the fact, that '2620' in the last example is not 5 digits long? I fiddled a bit with the '^^f0' and every variation (i.e. '^^0f', '^^ab', '^^08', ...) either led to an error or didn't combine either of the mentioned emoji.

The question, again: How does '^^f0' work?

  • this is primitive tex syntax (and with the two ^^ form works even in classic tex). it just means the character with code f0 so U+00F0 luatex and xetex extend the syntax to allow ^^^^2020 to refer to a larger range – David Carlisle Oct 18 '17 at 18:52
5

this is primitive tex syntax (and with the two ^^ form works even in classic tex). it just means the character with code hex f0 so U+00F0 luatex and xetex extend the syntax to allow ^^^^2020 to refer to a larger range

so you do not need expl3 or even latex, just primitive tex syntax

\show ^^77

produces

> the letter w.
l.2 \show ^^77

as in fact does

\sho^^77 w

which produces

> the letter w.
l.2 \show w

? 

the ^^ substitution is at a very early stage even before command names are tokenized.

Luatex uses an extended syntax allowing four or 6 ^ (but not 3 or 5) so you are probably looking for

^^^^^^01f3f4

In xetex or luatex the character U+1F1EA is a single character token with character code hex 1f1ea so it would not match a test for being the character with code hex f0, in pdftex it is the four character tokens with character codes hex f0 9f 87 aa (because character=byte=octet in pdftex) so if you look for the next character you just see the first byte of the utf8 encoding which is the character hex f0.

| improve this answer | |
  • Thanks, that's a start. But why does ^^f0 match 1f1ea, 1f308, ... in pdflatex? \show gives me \UTFviii@four@octets but 1f1ea etc. have 5 octets, haven't they? – genericFJS Oct 18 '17 at 19:55
  • 1
    @genericFJS no utf8 encoded character takes more than four octets in UTf-8 see en.wikipedia.org/wiki/UTF-8#Description – David Carlisle Oct 18 '17 at 20:01
  • U+1f1ea in UTF-8 is: F0 9F 87 AA – David Carlisle Oct 18 '17 at 20:04
  • Ok, I confused something. But that still does not explain to me, why ^^f0 matches 1f1ea and not 2620 when using \peek_charcode with pdflatex. And why does it not match anything when using lualatex/xelatex? – genericFJS Oct 18 '17 at 20:15
  • 1
    @genericFJS in xetex the character is a single character token with character code hex 1f1ea so it would not match a test for being the character with code hex f0, in pdftex it is the four character tokens with character codes hex f0 9f 87 aa (because character=byte=octet in pdftex) so if you look for the next character you just see the first byte of the utf8 encoding which is the character hex F0 – David Carlisle Oct 18 '17 at 20:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.