%%% Unicode engine detection with ASCII

% We want to test whether we are using an engine like Lua\TeX\ or Xe\TeX\ that
% supports Unicode. The 2009 pearl by Arthur Reutenauer is very nice and compact,
% but it needs a proper UTF-8 character. Here is another test that uses only ASCII.

\newif\ifunicodeengine
\begingroup
\catcode`\^=7 \catcode30=12 % just in case: 30 is `\^^^
\def\gobble#1{}
\edef\next{\gobble^^^^0021}
\expandafter\endgroup
\ifx\next\empty\unicodeenginetrue\else\unicodeenginefalse\fi

% With an 8-bit engine, \type{\gobble} will swallow only \verb|^^^| (ASCII 30), leaving
% \type{\next} expand to \verb|^0021|, while Lua\TeX\ and Xe\TeX\ have the extended 
% \verb|^^^^| convention that will make \type{\gobble} eat up \verb|^^^^0021|, 
% leaving \type{\next} expand to nothing. We just hope that! (ASCII 0x21) has not category
% code 9 or 14! And that \type{\empty} is still empty.
