Using English and Russian in verbatim

languagesluatexrussianverbatim

I want to use verbatim to type both English and Russian in the same block.

\usepackage[utf8]{inputenc}
\usepackage[russian, english]{babel}
\usepackage[T1, T2A]{fontenc}
\usepackage{fontspec}

\begin{document}

\begin{verbatim}
Hello - привет
\end{verbatim}

This doesn't work, on the PDF the Russian part is blank, and when I copy it shows these question marks:

Hello - ������

Russian text works fine in the rest of the document, it seems only to be in verbatim that it doesn't. I'm using LuaLaTex on Overleaf, and have tried the other options available and they messed things up even more with the rest of the document, so a solution with LuaLaTex would be ideal. Does anyone have any suggestions?

Best Answer

It works fine if you setup a mono font which supports russian:

\documentclass{article}
\usepackage[russian, english]{babel}
\usepackage{fontspec}
\setmainfont{dejavuserif}
\setmonofont{dejavusansmono}
\begin{document}

Hello - привет

\begin{verbatim}
Hello - привет
\end{verbatim}
\end{document}

enter image description here