Changes

Jump to navigation Jump to search
874 bytes added ,  20:19, 31 October 2007
Taco's trick to test for UTF-8-aware TeX engine
The [http://www.luatex.org official website] offers some more information.
 
== Some tricks ==
 
=== Testing for UTF-8-aware TeX ===
 
<i>(By [[User:Taco|Taco]]); this hint should be place to a better location on the wiki</i>
 
For luatex, one may test if <code>\luatexrevision</code> is defined.
 
The next weird macro definition should work for testing xetex/luatex, because only xetex and luatex accept 5- and 6-byte caret notation (hex 22 == double quote):
<texcode>
\def\"{0}\expandafter\def\csname^^^^^00022\endcsname{1}
\ifnum\"=0 \message{tex82}\else\message{newstuff}\fi
</texcode>
 
But that is not quite the same as testing for native UTF-8. Better is a trick like this:
 
<texcode>
\def\test#1#2!{\def\secondarg{#2}}
\test χ!\relax % That's Chi, a 2-byte utf-8 sequence
\ifx\secondarg\empty \message{newstuff}\else \message{tex82}\fi
</texcode>
 
ConTeXt offers <code>\beginNEWTEX ... \endNEWTEX</code> to test if one is using LuaTeX or XeTeX.

Navigation menu