5

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.

  • 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. – erreka Jan 29 '16 at 5:56
6

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.

  • doesn't csplain depend on the encTeX extension, as I already pointed out? – erreka 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? – erreka 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
  • I know... but your proposed solution assumes the OP is using an 8bit TeX engine, and afaik, they can't activate single tokens over the 7bit range with XeTeX or LuaTeX. afaics, the OP is only assuming the use of the Plain TeX macros, so they can use Plain TeX with the XeTeX or LuaTeX engine. – erreka Feb 1 '16 at 19:02
2

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.