I kept thinking about using Cyrillic characters in command names with PDFTeX engine. It looks to me so far that if I stay with 8-bit encoding and assign category code 11 to all Cyrillic letters except ё/Ё, this would be a working solution, except that bookmarks created with hyperref will be misencoded.
A workaround to fix PDF bookmarks created with hyperref would be to temporarily set category codes back to 13 for sectioning commands, and to not use commands with Cyrillic letters inside sectioning commands, or to use \texorpdfstring, like so:
\documentclass{article}
\usepackage[T2A]{fontenc}
\usepackage[cp1251]{inputenc}
\usepackage[russian]{babel}
\usepackage[unicode]{hyperref}
\catcode`л=11\relax
\catcode`п=11\relax
\catcode`к=11\relax
\newcommand{\лк}{«}
\newcommand{\пк}{»}
\begin{document}
{\catcode`л=13\relax
\section{Раздел «Первый»}}
{\catcode`л=13\relax
\gdef\pdfbookmarkname{Раздел «Второй»}}
\section{\texorpdfstring{Раздел \лк Второй\пк}{\pdfbookmarkname}}
\end{document}
This document, when compiled, has properly encoded bookmarks.
What would be an efficient way to set category code for the whole range of Cyrillic letters, except ё/Ё?
hyperref? – Alexey Jul 07 '18 at 11:14russlhpackage. – Alexey Jul 07 '18 at 11:20