# TikZ: Random characters with tikz, fontenc and input

I am getting random characters displayed in my TikZ images:

I have just noticed this recently. I am not sure what this might be caused by. I am using the latest TikZ build from TeXample.

I only observe this behaviour, when I create the image by using \input{} on my TikZ code, like so:

\documentclass{minimal}

\usepackage[T1]{fontenc}

\usepackage{tikz}

\begin{document}
\input{test.tikz}
\end{document}


Where test.tikz is just:

\begin{tikzpicture}%
\draw (-1,0) -- (1,0);
\end{tikzpicture}


If I were to directly insert the TikZ code (without inputing an external file), everything works nicely:

Also, removing \usepackage[T1]{fontenc} "fixes" the problem.

Any ideas what's going on there?

-
You probably have a BOM (byte ordering mark) in the input file. –  egreg May 30 '12 at 22:52
@egreg: Great! :D What am I to do about that? –  mSSM May 30 '12 at 23:02
It depends on what editor you're using. Find in its preferences something regarding BOM. –  egreg May 30 '12 at 23:06
Also if it doesn't mention BOM anywhere obvious but does mention encodings save as ascii rather than utf-8. –  David Carlisle May 30 '12 at 23:07
Well, it is ascii: ❯ file -i test.tikz \n test.tikz: text/plain; charset=us-ascii –  mSSM May 30 '12 at 23:10

This diagnosis is confirmed by the evidence you give: avoiding inputting the file doesn't show the characters. If you remove \usepackage[T1]{fontenc}`, you'll be using OT1 encoded fonts that have nothing in those slots (and you'll get "Missing character" messages in the log file).