# How to properly use UTF8 with latexdemo package

I want to have Umlauts in a latexdemo environment.

MWE:

\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage{textcomp}
\usepackage{latexdemo}

\begin{document}
\begin{filecontents*}{\democodefile}
Großschreibung
\end{filecontents*}

\PrintDemo{style=parallel}

\end{document}


pdflatex compilation error:

! Package inputenc Error: Unicode char ├\lst@ECƒ (U+9E9F)
(inputenc)                not set up for use with LaTeX.


Sure, it compiles fine with lualatex.

I tried adding listingsutf8, I assume, there is more configuration needed?

\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage{textcomp}
\usepackage{latexdemo}
\usepackage{listingsutf8}

\begin{document}
\begin{filecontents*}{\democodefile}
Großschreibung
\end{filecontents*}

\PrintDemo{style=parallel}

\end{document}

• You are almost there, but you did not read the lstlistingsutf8 manual, it does nothing on its own. Try adding \lstset{inputencoding=utf8/latin1 }, and remember this only works for characters representable in latin1 – daleif Mar 9 '18 at 15:37
• not all chars will work without problems with lualatex. Try out e.g. cœur. See also tex.stackexchange.com/questions/25391/… – Ulrike Fischer Mar 9 '18 at 15:49
• @daleif This solves my issue. Could you convert your comment t a full answer. With the additional not of @UlrikeFischer? – koppor Mar 9 '18 at 19:53

You are almost there, but you did not read the lstlistingsutf8 manual, it does nothing on its own. Add
 \lstset{inputencoding=utf8/latin1  }