\documentclass{minimal}
\usepackage{ucs}
\usepackage[utf8]{inputenc}
\usepackage[danish]{babel}
\usepackage{listings}
\begin{document}
Here is some java code:
\lstset{language=java, inputencoding=utf8}
\begin{lstlisting}
public void test() {
//A danish letter in a comment: Å
System.out.println("Hello World!");
}
\end{lstlisting}
\end{document}
If i save the above example in UTF-8 and runs latex on it, I get errors:
! Package ucs Error: Unknown Unicode character 65533 = U+FFFD,
(ucs) possibly declared in uni-255.def.
(ucs) Type H to see if it is available with options.
See the ucs package documentation for explanation.
Type H <return> for immediate help.
...
l.14 ...n kommentar med et dansk bogstav: ^^c3^^85
! Package utf8 Error: Character 133 appeared alone.
See the utf8 package documentation for explanation.
Type H <return> for immediate help.
...
l.14 ...n kommentar med et dansk bogstav: ^^c3^^85
If I save the example in ISO8859-1 and changes the encodings to latin1,
everything works fine. Futhermore, if I doesn't use listings, UTF-8
encoding works fine (also with danish letters).
If I doesn't set any inputencoding for my listing, the situation is the
same: With UTF-8 I get errors.
Is this a bug in the listings-package, or am I overlooking something?
TIA
Kasper
> I would like to inklude som java-source in my LaTeX document. My
> java-files are encoded in UTF-8, but when setting inputencoding=utf8 in
> my lstlisting, I get errors from latex regarding danish letters.
[..]
> Is this a bug in the listings-package, or am I overlooking something?
I had almost the same problem: java and German letters. So I posted in the
German usegroup and there they agreed that it is probably a bug. Then I
sent a bug report to the author but still didn't get any reply... On CTAN,
there is no new version. So I guess you have to save the listing as e.g.
latin1.
Sebastian
Thank you for your answer. At least it's not mee being stupid then ;-)
I'll check CTAN for a new version now and then. Should I send a
bug-report, or is there an official way to report and track bugs for a
package?
Best regards
Kasper
unless the author sets up an "official" way of doing it, your only
chance is to send the author a bug report direct.
--
Robin (http://www.tex.ac.uk/faq) Fairbairns, Cambridge