# What output encoding does latexdiff use?

I'm trying to use latexdiff on two versions of a document. These are encoded in UTF8 and have the \usepackage[utf8]{inputenc} statement as first line within the preamble.

I processed the files then using

latexdiff --encoding=utf8 file1.tex file2.tex > out.tex


but when I try to open out.tex with TexMaker again and I specify UTF8 as encoding, all the characters like äöüé show up as some gibberish characters. I assume this means that latexdiff does not use UTF8 as output encoding, but what encoding does it use?

This is on Windows 10 using MikTex and TexMaker and Strawberry Perl (doesn't work with Active State Perl either).

EDIT: Due to the observations below I have to conclude that latexdiff OR texmaker do not use the correct UTF8 encoding.

I now made two new toy documents in TexMaker (without any umlauts or other special characters), which is set to UTF8 in the settings:

\documentclass[10pt]{report}
\usepackage[utf8]{inputenc}
\title{Test1}
\begin{document}
\maketitle
\chapter{intro}
what is love?
\begin{itemize}
\item item
\end{itemize}
\end{document}


document2:

\documentclass[10pt]{report}
\usepackage[utf8]{inputenc}
\title{Test2}
\begin{document}
\maketitle
\chapter{intro}
what is hate?
\begin{itemize}
\item item2
\end{itemize}
\end{document}


Running the command latexdiff .\doc1.tex .\doc2.tex > diff.tex results in following diff.tex (when opened with TexMaker, selecting UTF8 when asked in the popup). (When I try to paste the text here, nothing is pasted, hence the image.)

The document does however look correct when I open it with the UTF16 setting:

\documentclass[10pt]{report}
%DIF LATEXDIFF DIFFERENCE FILE
%DIF DEL .\doc1.tex   Mon Sep 11 13:46:31 2017
%DIF ADD .\doc2.tex   Mon Sep 11 13:46:26 2017
\usepackage[utf8]{inputenc}
%DIF PREAMBLE EXTENSION ADDED BY LATEXDIFF
%DIF UNDERLINE PREAMBLE %DIF PREAMBLE
\RequirePackage[normalem]{ulem} %DIF PREAMBLE
\RequirePackage{color}\definecolor{RED}{rgb}{1,0,0}\definecolor{BLUE}{rgb}{0,0,1} %DIF PREAMBLE
\providecommand{\DIFdel}[1]{{\protect\color{red}\sout{#1}}}                      %DIF PREAMBLE
%DIF SAFE PREAMBLE %DIF PREAMBLE
\providecommand{\DIFdelbegin}{} %DIF PREAMBLE
\providecommand{\DIFdelend}{} %DIF PREAMBLE
%DIF FLOATSAFE PREAMBLE %DIF PREAMBLE
\providecommand{\DIFdelFL}[1]{\DIFdel{#1}} %DIF PREAMBLE
\providecommand{\DIFdelbeginFL}{} %DIF PREAMBLE
\providecommand{\DIFdelendFL}{} %DIF PREAMBLE
%DIF END PREAMBLE EXTENSION ADDED BY LATEXDIFF

\begin{document}
\maketitle
\chapter{intro}
\begin{itemize}
\item \DIFdelbegin \DIFdel{item
\end{document}


But as soon as I try to compile it using pdflatex I get the error

line 1 ! Undefined control sequence. \

• @egreg How can you check whether you get the correct format? – flawr Sep 10 '17 at 13:02
• I've never had a problem and I don't even specify the encoding option. (Unless I stuck it in a config file.) And all my files use UTF8 and include at least some non-ASCII characters (curly quotes, if nothing else). – cfr Sep 10 '17 at 13:05
• I simply opened the file with a UTF-8 editor. Not Notepad++, of course, which I cannot run and is known to add a BOM all around. – egreg Sep 10 '17 at 13:06
• On a UNIX-ish system, you can say file <path> to get the encoding (and other information) about the file at <path>. Not sure on Windows, though. – cfr Sep 10 '17 at 13:06
• Unfortunately the "solution" above does not work for my real documents. The outputs with and without the --e=utf8 are identical. – flawr Sep 10 '17 at 13:30

2. Remove all \left and \right which is another issue of latexdiff
3. Comment out all tikz pictures (in my case it was enough to comment all \tikzsetnextfilename as well as %\usetikzlibrary{external} and \tikzexternalize[prefix=tikz/]), see also here.
4. Run latexdiff .\doc1.tex .\doc2.tex > diff.tex
5. Open diff.tex with NotePad++. The current encoding is UCS2-Little-Endian, but we need to use Convert to UTF8-without-BOM, and save the document.
6. Open the diff.tex in TexMaker, now no dialog box about encoding should pop up, and the document should compile fine.