How I can display properly polish characters in code of programming language using listings package and lualatex compiler?
main.cpp:
//Zażółć gęślą jaźń
#include <iostream>
int main() {
std::cout << "Hello World!\n";
return 0;
}
main.tex:
\documentclass[12pt, a4paper]{article}
\usepackage[polish]{babel}
\babelprovide[transforms = oneletter.nobreak]{polish}
\usepackage{listings}
\usepackage{xcolor}
\definecolor{codegreen}{rgb}{0,0.6,0}
\definecolor{codegray}{rgb}{0.5,0.5,0.5}
\definecolor{codepurple}{rgb}{0.58,0,0.82}
\definecolor{backcolour}{rgb}{0.95,0.95,0.92}
\lstdefinestyle{mystyle}{
backgroundcolor=\color{backcolour},
commentstyle=\color{codegreen},
keywordstyle=\color{magenta},
numberstyle=\tiny\color{codegray},
stringstyle=\color{codepurple},
basicstyle=\ttfamily\footnotesize,
breakatwhitespace=false,
breaklines=true,
captionpos=b,
keepspaces=true,
numbers=left,
numbersep=5pt,
showspaces=false,
showstringspaces=false,
showtabs=false,
extendedchars=true,
tabsize=2
}
\lstset{style=mystyle}
\hbadness=99999
\begin{document}
\lstinputlisting[language=C++]{main.cpp}
\end{document}
First result (lualatex):
My goal is to have the result, as the picture below (in lualatex compile):
Many thanks in advance!



\usepackage[T1]{fontenc}with lualatex. – Ulrike Fischer Jul 30 '22 at 21:38fontenc? – constantin_d Jul 31 '22 at 11:27