1

I have a problem using lstlisting environment with utf8 encoding. I got this error

 Package inputenc Error: Unicode char \u8:�\expandafter not set up for use wit  

MWE

\documentclass{article}
\usepackage[frenchb]{babel}
\usepackage[utf8]{inputenc}
\usepackage{listings}
\begin{document}
\begin{lstlisting}
  {entête}.{informations}.{signature} 
\end{lstlisting}
\end{document}
-1

You can use:

\lstset{literate=%
    {á}{{\'a}}1
    {é}{{\'e}}1
    {è}{{\`e}}1
    {í}{{\'i}}1
    {ó}{{\'o}}1
    {ú}{{\'u}}1
}
  • Please explain your answer. It doesn't even work. You make a comment here. – Hunsu May 25 '14 at 13:53
  • You can set the environment listings. Yo can put the before code after \usepackage{listings}, in the preamble. – jpayansomet May 25 '14 at 14:12
  • 2
    @jpayansomet You should explain what this code does and why it works, since the OP has mentioned that it won't work (and in fact, it won't work) – darthbith May 25 '14 at 14:13
  • Sorry. I have forgotten you must modified the load of packet and you can put \usepackage[formats]{listings}. That code permits to replace {è} with {`e}. – jpayansomet May 25 '14 at 14:28
  • This is the MWE:\documentclass{article} \usepackage[frenchb]{babel} \usepackage[utf8]{inputenc} \usepackage{listings} \lstset{literate=% {ê}{{\^e}}1 } \begin{document} \begin{lstlisting} {entête}.{informations}.{signature} \end{lstlisting} \end{document}. I had confused the acute. Sorry – jpayansomet May 25 '14 at 14:36

Not the answer you're looking for? Browse other questions tagged or ask your own question.