# Hide ^^^^-notation from pdftex

The following example gives when compiled with pdflatex the error

! Text line contains an invalid character.

\documentclass{article}
\usepackage{ifluatex}
\ifluatex
\usepackage{fontspec}
\fi
\begin{document}
abc
\ifluatex ^^^^20ac\fi
\end{document}


It is possible to get around the problem by using another char and changing its catcode e.g. inside the ifluatex:

\ifluatex{\catcode\!=7 !!!!20ac}\fi


But I'm wondering: Is there a way to hide such invalid characters from ^^^^-notation in some way globally in pdflatex?

-
\ifluatex\input{20ac.unicode}\fi and have a file for each unicode character. But that doesn't sound like a good solution, does it? :-/ –  yo' Apr 23 at 8:31
@tohecz: sound like cheating ;-). Also one would probably get problems in some places (additional spaces, \input not allowed). –  Ulrike Fischer Apr 23 at 8:40
I think the easiest thing is to not use ^^^^^ but instead just use the character directly in utf-8 € then you can load \usepackage[utf8]{inputenc} for pdftex –  David Carlisle Apr 23 at 8:48
couldn't you use \char"20AC instead of ^^^^20ac? –  Herbert Apr 23 at 8:51
@Herbert: In some places certainly but you couldn't e.g. change the catcode of ^^^^20ac. –  Ulrike Fischer Apr 23 at 9:00

The invalid character is ^^^, that is, 0x1E; LaTeX, by default, makes all characters from 0x01 to 0x1F invalid, with the exception of

0x09 0x0C 0x0D


that is, tab, line feed and carriage return (category codes 10, 13 and 5).

A workaround could be making this character ignored:

\documentclass{article}
\usepackage{ifluatex}
\ifluatex
\usepackage{fontspec}
\else
\catcode\^^^=9
\fi
\begin{document}
abc
\ifluatex ^^^^20ac\fi
\end{document}


Assuming you don't need ^^^ anywhere in pdflatex code, this should keep TeX happy.

-
Imho this is perfect. I can't imagine what harm it should do as ^^^ would give an error anyway. –  Ulrike Fischer Apr 23 at 9:09
This is so genuine! –  yo' Apr 23 at 10:51