# Using enctex with XeLaTeX

Can I use `enctex` with XeLaTeX? I want use it as it's a requirement for `encxvlna` (package that inserts non-breaking space into Czech documents).

All documents howto use it describe just `pdflatex` configuration.

• A binary like `pdftex` is specially compiled in order to be configured for usage of encTeX. This is not the case for XeTeX or LuaTeX, mainly because they use much larger character tables than encTeX knows. As far as I know, encTeX reads UTF-8 byte by byte, so it only emulates Unicode input. See section 2 in the documentation of encTeX. – egreg Nov 17 '15 at 13:09

## 2 Answers

The impossibility of using encTeX with XeTeX and LuaTeX results from sections 2 and 3 of the manual.

The encTeX extensions is only able to emulate UTF-8 input, while still reading a file one byte at a time. It does so when reading the bytes, so for example something like

``````\mubyte \foo ABCD\endmubyte
``````

can be declared, which changes `ABCD` into `\foo` before macro expansion takes place. Sequences are recognized until there's a match with one that's defined.

This means that the level encTeX operates at comes after multibyte conversion into a single Unicode entity has taken place with XeLaTeX and LuaLaTeX. For instance, if the input file is UTF-8 encoded, the multibyte sequence `^^c3^^a1` (I'm using the usual TeX representation) is transformed into the entity `U+00E1` (that is, LATIN SMALL LETTER A WITH ACUTE) before tokenization is performed and category codes are assigned. Since encTeX still works with `xord` and `xchr` arrays with 256 slots, it cannot understand such extended entities.

Maybe this problem can be solved, but, as things stand, XeTeX and LuaTeX cannot be compiled to accept the `-enc` option for enabling usage of encTeX.

OK, while I'm not sure, whether I can use `enctex` with XeLaTeX (probably not), I found `xevlna` – XeTeX / XeLaTeX package with similar functionality as `encxvlna` for TeX / LaTeX.