I'm trying to insert source code in LaTeX with using listings, but my code has accents and pdflatex gives me this error:
Unicode char \u8:�\expandafter not set up for use with LaTeX.
This is a code the reproduces the error.
example.tex
\documentclass{article}
\usepackage{listings}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}
\begin{document}
\lstinputlisting[language=C++]{code.cpp}
\end{document}
code.cpp
// Código con una tilde
What can I do to generate the PDF correctly?
lstinputlisting. For environment e.g.\begin{lstlisting}see unicode - Having problems with listings and UTF-8. Can it be fixed? - TeX - LaTeX Stack Exchange. – user202729 Jul 31 '22 at 15:10