I have some code snippets in which I'd like to use the characters ĉ,ĝ,ĥ,ĵ,ŝ,ŭ. However the listings package is unable to process them well, resulting in compilation errors or other oddities. my MWE using lualatex:
\documentclass[12pt]{article}
\usepackage[utf8x]{inputenc}
\usepackage{listings}
\usepackage{fontspec}
\begin{document}
\begin{lstlisting}
tagmango
\end{lstlisting}
\begin{lstlisting}
tagman\^go
\end{lstlisting}
\begin{lstlisting}
tagmanĝo
\end{lstlisting}
\end{document}
this is the result with fontspec commented out:
this is the result time using fontspec:
this post and this one seemed to have a solution using some specific listings command, but I just don't understand the inner workings of this solution (is the argument a list encoding every desired unicode character? is it just a long voodo string that does something?) and how to minimally adapt it to my use case. couldn't find any mention of it in the listings' package manual either.


^^^^i front. Here g-har is^^^^011d(i just googled g hat unicode) – daleif Jul 21 '18 at 11:43mintedas an alternative tolistings, that would (probably) work well with utf8 characters. – Marijn Jul 21 '18 at 22:05