Trying to include a source-file into my latex document using the listings package, i got problems with german umlauts inside of the comments in the code. Using
\lstset{ extendedchars=\true, inputencoding=utf8x }
Umlauts in the source files (encoded in UTF-8 without BOM) are processed, but they are somehow moved to the beginning of the word they are contained in. So
// die Größe muss berücksichtigt werden
in the input source file, becomes
// die ößGre muss übercksichtigt werden
in the output file.
NOTE: since i found errors in my initial setup, i heavily edited this question
UTF-8 is the most widely used character encoding on the web today. You can use it to represent any unicode character, which includes an enormous variety of letters, numbers and symbols, including Greek letters and letters with accents.
It's definitely UTF-8.
UTF-8 (UCS Transformation Format 8) is the World Wide Web's most common character encoding. Each character is represented by one to four bytes. UTF-8 is backward-compatible with ASCII and can represent any standard Unicode character.
I found a simpler approach, which works for me:
\usepackage{listings} \lstset{ literate={ö}{{\"o}}1 {ä}{{\"a}}1 {ü}{{\"u}}1 }
For comments only, you can use the texcl
option:
\lstset{language=C++,texcl=true}
Than your comments become Latex and you can use "special" characters
\begin{lstlisting} int iLink = 0x01; // Paramètre entrée \end{lstlisting}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With