Changes

Jump to navigation Jump to search
→‎Input Regimes: Moved 'detecting UTF-8' tip here
If you write ConTeXt source documents and use more than 7-bit ASCII, you must decide on the encoding of your file. That’s a matter of your text editor.
The best choice is normally UTF-8, but if you insist to use an outdated editor that can’t handle Unicode properly or if you’re forced to use legacy code, you have to choose the proper 8-bit encoding, see below.
 
=== Testing for UTF-8-aware TeX ===
 
To test for [[LuaTex]], one may test if <code>\directlua</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 process code conditional on using LuaTeX or XeTeX.
===Available Regimes===
 
<table style="border:1px solid #DDDDDD">
<tr style="background-color:#DDDDDD"><th>ConTeXt name(s)</th><th>Official name(s)</th><th>Remarks</th></tr>

Navigation menu