Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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:

 \usepackage[utf8]{inputenc}

What should I do?

share|improve this question
3  
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
1  
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 at 13:20

2 Answers 2

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 1 down vote accepted

I just solved it in using

  inputencoding=latin1

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

share|improve this answer

Your Answer

 
discard

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.