3

I was experimenting with plain TeX, and, I thought, since I knew it reads input files using ASCII (right?), it would surely give me an error if I asked for a non-ASCII character's numbers. I tried this:

\number `ا

ا being the Arabic letter Aliph. What's weird is that it returned 216. I tried this with the rest of the Arabic letters, and the same number was on the screen. I have two questions: First, why hasn't TeX given me an error (like how pdfLaTeX would do); second, why do all Arabic characters have the same character number? What's weirder is that Greek letters have a different behavior, where some of them have similar numbers, but other have unique numbers. I'm using pdfTeX.

Just tested the same thing with XeTeX, totally different numbers where outputted, each number different and unique.

Can someone please explain what's happening?

1
  • 1
    your char is encoded in utf8 as 0xD8 0xA7, plain tex sees the first byte, and as D8=216 you get this number. In pdflatex the first bytes is an active char (to handle utf8 input) and so you get an error. xetex would report the unicode number of the char. Commented Mar 30, 2021 at 14:15

1 Answer 1

7

Your char is encoded in utf8 as 0xD8 0xA7, plain tex sees the first byte, and as D8 (hex) = 216 (dec) you get this number.

In pdflatex the bytes are active chars (to handle utf8 input). The second byte (A7) gives an error when used on its own and so you get an error when the \number grabs the first bytes. By redefining the second byte you can see that the first gives you a 216 too:

\documentclass{article}
\begin{document} 

\def^^a7{blub}
\number `ا 
\end{document}

enter image description here

xetex would report the unicode number of the char

1
  • Thanks for the explanation, it's interesting nugget of information! Commented Mar 30, 2021 at 14:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .