[Tex/LaTex] inputenc[utf8] error with input-function of external tex files

charactersinput-encodingsrtablesunicode

I got a problem with inputenc[utf8]. My document is in German and uses 'ä, ö, ü' which usually works fine with the following preamble:

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}

I am using Texstudio for writing my document if that matters. The external tex files are only xtables produced by R. These are saved as .tex files, and put into my document via the \input{./file.tex} function. This also works well.
The problem is, when I add captions in German to the tables (e.g. sthg like 'ääääääää'), the following error results when compiling:

Package inputenc Error: Unicode char \u8:ä not set up for use with LaTeX ...

Is there any way I can circumvent this? I have the feeling the problem is that the above preamble is not part of tables produced by xtable in R. These have the following simple format (not separate preamble, just the following):

% latex table generated in R 3.0.1 by xtable 1.7-1 package
% Sat Nov 28 00:05:12 2013
\begin{table}[htbp]
\caption{ääää}
\begin{tabular}{ l c r }
 1 & 2 & 3 \\
 4 & 5 & 6 
\end{tabular}
\end{table}

But then again these files should be included into the original document via the input-function just fine? I dont get the problem. You can test this hopefully by saving the above table under a separate tex file, then including it at the beginning of the document:

\documentclass[a4paper]{scrreprt}
\usepackage{setspace}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}

\begin{document}
\input{./file.tex} % assuming you called it 'file'
\end document

Thanks for any hints. I am using Win 7 x64 and Miktex 2.9.

Best Answer

If you can not save the files in UTF8 just tell LaTeX what encoding they are in, most likely latin1 (ISO-8859-1) so:

{\inputencoding{latin1}\input{file.tex}} 
Related Question