20

I have inherited a semi-small TeX project in which I, after syncing across various computers and OS'es, had some problems with encodings of special characters like åäö.

My initial approach for fixing this was to convert everything to UTF-8 (using the iconv utility on Ubuntu), which made all the weird incorrect replacement characters disappear. However, the special characters still don't show up.

If this was LaTeX, I'd do \usepackage[T1]{fontenc}, but that doesn't work here because I compile with pdftex.

What do I do instead?

4
  • Is pdftex utf8 agnostic? You probably need xetex or luatex and you have to specify a font that supports these chars. BTW: interesting question.
    – daleif
    Commented Aug 26, 2015 at 10:55
  • There is no specific encoding support in plain, just load a T1 (8t) encoded font using \font. Commented Aug 26, 2015 at 10:55
  • 2
    Are you sure you want UTF8 it would be much easier to handle latin 1 in plain TeX. Commented Aug 26, 2015 at 10:56
  • So, are you using pdftex with utf8 encoded files?
    – jarnosz
    Commented Sep 1, 2015 at 21:02

1 Answer 1

17

At first you don't need an equivalent for fontenc but for inputenc. You should (like inputenc) make the non-ascii chars active and map them to suitable commands. E.g. in an 8-bit encoded file you could do something like this:

%OT1-encoded font
\catcode`\ä=13
\defä{\"a}

Räuber
\bye

enter image description here

When using a T1-encoded font life is a bit easier, as a lot of chars are already in "the correct position". So the catcode changes are often not really needed, but as you can see with the ß some chars can be wrong if you don't add a definition

%Use a T1-encoded font:
%\catcode`\ä=13
%\defä{\char"E4}
% \catcode`\ß=13
% \defß{\char"FF}
%
\font\test=ecrm1000 \test

Räuber öäüß
\bye

enter image description here

With an utf8 encoded file life gets much more complicated as then you will have to recreate the parsing of the utf8 octets.

Addition

With the csplain or pdfcsplain format (http://petr.olsak.net/csplain-e.html) you can use utf8 directly.

öäüß

\bye

enter image description here

4
  • The first case breaks the \uppercase command, you don't get uppercased accented letters. And the second is interesting because when you write an external file it is written with a different encoding, so a table of contents does not work with that. Any idea on solving that without csplain?
    – blmayer
    Commented Jan 15, 2016 at 17:27
  • @BrianMayer: Use latex. Why reinvent the wheel? Commented Jan 15, 2016 at 18:00
  • Hahaha never mind, figured that out with this. I like minimalistic stuff, plus the nostalgia.
    – blmayer
    Commented Jan 15, 2016 at 19:02
  • I don't think "we don't need such package" is sufficient to avoid the core of question ("an equivalent package...") Commented Mar 30, 2021 at 14:21

You must log in to answer this question.

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