[Tex/LaTex] polish characters ą

listings

I cannot get to work my special chars in listings, my texmaker is configurated to use utf8 in options, but I get error:

! Package inputenc Error: Unicode char \u8:�\lst@FillFixed@ not set up for use
with LaTeX.

With XeLatex i dont get any errors but it doesn't show any ą in pdf. Could i import the content of file.txt and show it in C# colors without copy-paste to .tex file?

\documentclass[titlepage, a4paper]{mwart}
\usepackage{amsmath,amsfonts,amssymb,amsthm}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{polski}
\usepackage{graphicx}
\usepackage{listings}
\usepackage{xcolor}
\lstdefinestyle{sharpc}{language=[Sharp]C, frame=lr, rulecolor=\color{blue!80!black}}
\begin{document}
ą
\begin{lstlisting}
ą
\end{lstlisting}


\end{document}

Best Answer

You can use literate to replace the char with a suitable command:

\documentclass[titlepage, a4paper]{mwart}
\usepackage{amsmath,amsfonts,amssymb,amsthm}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{polski}
\usepackage{graphicx}
\usepackage{listings}
\usepackage{xcolor}
\lstdefinestyle{sharpc}{language=[Sharp]C, frame=lr, rulecolor=\color{blue!80!black}}

\lstset{literate=%
    {ą}{{\k a}}1    
}
\begin{document}
ą 
\begin{lstlisting}
ą
\end{lstlisting}

\end{document}
Related Question