Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Listings and utf8 encoding

771 views
Skip to first unread message

Kasper G. Christensen

unread,
Mar 11, 2005, 2:06:37 AM3/11/05
to
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. I have
constructed a little example without external files, that illustrates
the problem:

\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

Sebastian Schubert

unread,
Mar 11, 2005, 4:17:16 AM3/11/05
to
Kasper G. Christensen wrote:

> 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

Kasper G. Christensen

unread,
Mar 15, 2005, 1:18:51 AM3/15/05
to
> 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.

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

Robin Fairbairns

unread,
Mar 15, 2005, 8:56:10 AM3/15/05
to

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

0 new messages