18

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?

  • 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 Aug 26 '15 at 10:55
  • There is no specific encoding support in plain, just load a T1 (8t) encoded font using \font. – David Carlisle Aug 26 '15 at 10:55
  • 2
    Are you sure you want UTF8 it would be much easier to handle latin 1 in plain TeX. – David Carlisle Aug 26 '15 at 10:56
  • So, are you using pdftex with utf8 encoded files? – texnezio Sep 1 '15 at 21:02
16

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

  • 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? – Brian Mayer Jan 15 '16 at 17:27
  • @BrianMayer: Use latex. Why reinvent the wheel? – Ulrike Fischer Jan 15 '16 at 18:00
  • Hahaha never mind, figured that out with this. I like minimalistic stuff, plus the nostalgia. – Brian Mayer Jan 15 '16 at 19:02

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.