# Turkish (İ) character inside code listings

I'm using listings package to put java code in my tex files. There are some Turkish characters in the code. So, I'm using the literate directive for them to appear correctly. Everything works fine other than the "İ" character, the capital I with a dot on top. This character is not rendered correctly. My code is as follows:

\usepackage{listings}

\lstset{
language=Java,
captionpos=t,
tabsize=3,
frame=single,
frameround=tttt
backgroundcolor=\color{highlight},
basicstyle=\footnotesize\ttfamily,
keywordstyle=\color{javapurple}\bfseries,
stringstyle=\color{javared},
numbers=left,
numberstyle=\tiny,
numbersep=5pt,
breaklines=true,
showstringspaces=false,
emph={label},
inputencoding=utf8,
extendedchars=true,
% German umlauts
literate=%
{Ö}{{\"O}}1
{Ä}{{\"A}}1
{Ü}{{\"U}}1
{ß}{{\ss}}1
{ü}{{\"u}}1
{ä}{{\"a}}1
{ö}{{\"o}}1
%Türkçe karakterler
{ı}{{\i}}1
{İ}{{\.{I}}}1    % This is the problem character.
{ğ}{{\u{g}}}1
{Ğ}{{\u{G}}}1
{ş}{{\c{s}}}1
{Ş}{{\c{S}}}1
{ç}{{\c{c}}}1
{Ç}{{\c{C}}}1
}

\begin{lstlisting}
System.out.println("Test: ı ü ğ ş ç ö, İ Ü Ğ Ş Ç Ö ");
\end{lstlisting}


The output of this is as follows:

The letter shows incorrectly with a line close to bottom of the letter. The correct output should be like "İ", with a dot on top. I have several options to solve this. But none worked. Does anybody have a solution? Thank you...

• You don't have \usepackage[T1]{fontenc}, add it to your preamble. – egreg Dec 19 '14 at 8:58
• How are the various java... colors defined? Which document class, and which other packages, do you load? – Mico Dec 19 '14 at 8:59
• As an alternative approach to using fontenc and inputenc, you may want to consider using a 'more modern' approch, with xelatex or lualatex, which process Unicode files directly, in place of pdflatex. (That's assuming you don't already have a big investment in legacy files.) – Brent.Longborough Dec 19 '14 at 9:54

I suggest you add the instructions

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}


The following example had to modify the color coding choices since you didn't provide information about how the various java... colors are defined.

\documentclass{article}
\usepackage[utf8]{inputenc}  % assumes input is utf8-encoded
\usepackage[T1]{fontenc}
\usepackage{listings}
\usepackage{xcolor}
\begin{document}

\lstset{
language=Java,
captionpos=t,
tabsize=3,
frame=single,
frameround=tttt
backgroundcolor=\color{highlight},
basicstyle=\footnotesize\ttfamily,
keywordstyle=\color{purple}\bfseries,
stringstyle=\color{red},
morecomment=[s][\color{blue}]{/**}{*/},
numbers=left,
numberstyle=\tiny,
numbersep=5pt,
breaklines=true,
showstringspaces=false,
emph={label},
inputencoding=utf8,
extendedchars=true,
% German umlauts
literate=%
{Ö}{{\"O}}1
{Ä}{{\"A}}1
{Ü}{{\"U}}1
{ß}{{\ss}}1
{ü}{{\"u}}1
{ä}{{\"a}}1
{ö}{{\"o}}1
%Türkçe karakterler
{ı}{{\i}}1
{İ}{{\.{I}}}1    % This is the problem character.
{ğ}{{\u{g}}}1
{Ğ}{{\u{G}}}1
{ş}{{\c{s}}}1
{Ş}{{\c{S}}}1
{ç}{{\c{c}}}1
{Ç}{{\c{C}}}1
}

\begin{lstlisting}
System.out.println("Test: ı ü ğ ş ç ö, İ Ü Ğ Ş Ç Ö ");
\end{lstlisting}
\end{document}

• Thank you for the answer. I actually already had the second line in my preamble, but not the first line. Adding that solved my problem... – Karşıbalı Dec 20 '14 at 23:45