TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to copy and past some UTF8 code into a lstlisting, but unfortunately, I receive the following error :

! Package inputenc Error: Unicode char \u8:�\lst@FillFixed@\lst@EC� not set up for use with LaTeX.

Keyboard character used is undefined

What is weird was that I didn't noticed any weird characters in my lstlisting code (it's some bash code). Furthermore I got the package in header:


What should I do?

share|improve this question
Please check the following TeX.sx link: tex.stackexchange.com/q/25391/19384. It explains the problem an dhow to get UTF8 into the lstlistings – Peter Jansson Jan 6 '13 at 22:07
A related potential issue is with \lstinputlisting:that you've used an editor that's been too clever, and the file that you thought wasn't utf8 now is, with some odd unicode characters hidden by the editor at the start. I was getting the same error message as this on the first line, whatever I put at the start of the file. The � may be a real unicode character U+FFFD:REPLACEMENT CHARACTER in the output. – Chris H Mar 14 '14 at 13:20

listings cannot handle UTF8-characters. Search in the docs for the keyword literate. Then you'll see how UTF-8 characters can be mapped to TeX commands, eg ü->\"u: \lstset{literate={ü}{{\"u}}1}

share|improve this answer
up vote 7 down vote accepted

I just solved it in using


I hope it can help some in the same case than me.

share|improve this answer

I solved adding texcl=true to the \lstset configuration.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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