6

In plain TeX,

\char<int>

produces character with decimal code <int>. Similarly,

\char'<oct>
\char"<hex>

produce character with octal code<oct>, and hexadecimal code <hex> respectively.

Is there such a way of typing Unicode symbols ?

Thank you.

2
  • 3
    In (Xe|Lua)TeX just \char"<hex> works, or may be the expandable \Uchar"<hex>. – Manuel Jan 29 '16 at 0:15
  • 1
    You need an unicode aware engine to do it; macro packages like Plain cannot do it by themselves. – jarnosz Jan 29 '16 at 5:56
7

You can somewhat emulate Unicode also with Plain TeX; say you want to input ć and get \'c out of it.

\catcode"C4=\active % 0xC4 is a two-byte prefix in UTF-8
\def^^c4#1{\csname\string^^c4#1\endcsname}

\expandafter\def\csname\string^^c4^^87\endcsname{\'c}
%%% add other UTF-8 characters having 0xC4 as prefix

%%% Repeat for all other UTF-8 prefixes you need

ć

\bye

Repeat for all prefixes.

You may want to look at http://petr.olsak.net/csplain-e.html for a different strategy and an already baked solution.

9
  • doesn't csplain depend on the encTeX extension, as I already pointed out? – jarnosz Jan 29 '16 at 16:59
  • @TarsTarkas Yes, that's why I said it uses a different strategy. – egreg Jan 29 '16 at 17:00
  • In any event, activating characters or transforming input is a whole different game than using the \char primitive, isn't it? – jarnosz Feb 1 '16 at 18:37
  • With TeX you can't use \char<number> with a number beyond 255, can you? You have to switch to XeTeX or LuaTeX for this, with many problems, of course. – egreg Feb 1 '16 at 18:54
  • 1
    @TarsTarkas No tag xetex or luatex is accompanying the question. With XeTeX you can certainly type \char"1234, but no output would result, unless you set up an OpenType/TrueType font. – egreg Feb 1 '16 at 19:04
3

You need an unicode aware engine to do it; macro packages like Plain cannot do it by themselves. Examples of unicode aware engines are xetex and luatex, and perhaps etex and pdftex with the enctex extension.

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.