# TeXLive and MikTeX behave differently in handling BOM in listing

This is a followup to a comment of mine posted in 2012. In short, MikTeX does not remove the leading BOM from listings, but TeXLive does, as shown in the following images. The leading BOM effect can be clearly seen by comparing the first line of the output (using System;) in listings produced with MikTeX and TeXLive.

### MWE

% The filename is MikTeX-VS-TeXLive.tex

\documentclass[preview,border=12pt]{standalone}

\usepackage{listings,xcolor}
\lstset
{
language={[Sharp]C},
backgroundcolor=\color{cyan!20},
basicstyle=\scriptsize,
keywordstyle=\color{blue},
identifierstyle=\color{red},
breaklines=true,
}

\begin{document}
\lstinputlisting{program.cs}
\end{document}


## Questions

What should I do to make MikTeX do the same thing as TeXLive does but without having to use literate?

Bonus question: Is the source code of pdflatex, xelatex, latex used for MikTeX exactly identical to that of for TeXLive? If yes, why do they behave differently? If the source code is different, why are they made differently?

• On my TeX Live I get the spaces at the beginning; of course I can't test MiKTeX. – egreg Jun 4 '14 at 21:09
• @egreg: Hmm... it looks weird. We have the same TeX Live I think. – kiss my armpit Jun 4 '14 at 21:11
• I can reproduce the behaviour on windows: TeXLive (2012, 2013 and 2014) pdflatex ignores the BOM. It is not related to listings. If I simply input the file and use T1-encoding then I see in miktex ïż£ but nothing in texlive. It looks as if windows binaries of texlive are clever ;-). And it would be worth a feature request to get the same for miktex. – Ulrike Fischer Jun 5 '14 at 7:11
• I can't comment -- thus as an answer to the first part of the bonus question: From experience, I'd say there are many differences between MikTeX and TeXlive implementations, especially when handling external files: MikTeX also supported including files with added extension using \include{filename.tex}, while TeXlive doesn't like that: No file test.tex.tex. MikTex did support downloading packages during compilation, while TeXlive didn't. – phi1010 Sep 20 '17 at 6:02
• I cannot reproduce this issue (the spacing problem) using: Windows MikTex with TeXstudio, encoding program.cs as UTF-8-BOM, and using any of: pdflatex, latex or xelatex. The output always looks like your "Output with TeXLive" – jessexknight Oct 13 '17 at 16:47

## Status in 2019

I can run a BOM TeX file concurrently through both systems and my current tests suggest presently there are no differences for the stated historic cause (3 hidden characters i.e. literate={ï}{}0 {»}{}0 {¿}{}0 )

Although there are other differences in file output !

MiKTeX-PdfLaTeX command compiles file as 25.9 KB (26,610 bytes) via

miktex-pdftex.exe $synctexoption --undump=pdfLaTeX$fullname


The 2018 TeX Live one is smaller 24.5 KB (25,145 bytes)

pdflatex.exe $synctexoption$fullname


Both pdf files appear identical in scale and visual content.