[Tex/LaTex] PDFLaTeX Undefined control sequence documentclass ^^@

errorspdftextexmaker

I've just started playing with texmaker today and I can't get a .tex file to compile, even for a simple helloworld file. Upon running the pdflatex command, I get a log file where the first error is:

! Undefined control sequence.
l.1 \^^@
    ^^@^^@d^^@^^@^^@o^^@^^@^^@c^^@^^@^^@u^^@^^@^^@m^^@^^@^^@e^^@^^@^^@n^...
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

This is the text in the .tex file:

\documentclass[11pt,a4paper]{report}
\usepackage[latin1]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\begin{document}
Hello, world!
\end{document}

which was generated by the wizard and I just inserted a line of test text. The command for pdflatex is given by:

pdflatex -synctex=1 -interaction=nonstopmode %.tex

which again is the default. Currently, the encoding font is UTF-32, but I seem to have the same problem no matter which encoding I choose.

Can anyone see what is going wrong? It seems that pdflatex is inserting ^^@ between every letter, but why? I couldn't find the same problem anywhere else online.

Thanks!

EDIT: Yes.. UTF8 works.. I'm so embarrassed, I was sure I tried it! Thank you very much! 🙂

Best Answer

It seems that your input source file is in UTF16 or UTF32. The UTF32 file includes (byte per byte):

zero zero zero \ zero zero zero d zero zero zero o zero zero zero c ...

TeX interprets \ zero as a control sequence with single character (ASCII-zero) and this control sequence (reported by TeX as \^^@ in log file) is not defined.

Use only ASCII or one-byte encoding or UFT8 for your source files.