# How to compare two macros containing Cyrillic?

Short question is: How to compare two macros containing Cyrillic?

It is not difficult to compare two strings with \ifx for Latin strings

\def\contentsnameinlanguage{Contents}
\ifx\contentsname\contentsnameinlanguage 1 \else 0 \fi % 1


But what if I want to do the same for Cyrillic strings?

\def\contentsnameinlanguage{Зміст}
\ifx\contentsname\contentsnameinlanguage 1 \else 0 \fi %


I would like to receive 1 in this case too.

Full MWE:

\documentclass{article}
\usepackage[T2A,T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english,ukrainian]{babel}

\begin{document}

\selectlanguage{english}
\def\contentsnameinlanguage{Contents}
\ifx\contentsname\contentsnameinlanguage 1 \else 0 \fi % 1

\meaning\contentsname

\selectlanguage{ukrainian}
\def\contentsnameinlanguage{Зміст}
\ifx\contentsname\contentsnameinlanguage 1 \else 0 \fi % 0

\expandafter\meaning\contentsname

\end{document}

• The problem of your comparison is, that the first definition of \contentsname after the \selectlanguage{ukrainian} is {\cyr \CYRZ \cyrm \cyrii \cyrs \cyrt } and not Зміст. – Skillmon Jul 25 '17 at 19:00
• @Skillmon I realised that – sergiokapone Jul 25 '17 at 19:02
• Comparing against \def\contentsnameinlanguage{{\cyr\CYRZ\cyrm\cyrii\cyrs\cyrt}} would work. The tokens simply don't match. – Skillmon Jul 25 '17 at 19:03
• You can make the compare with \ifx work with \edef\contentsnameinlanguage{{\cyrЗміст}} compared against \edef\contentsnameedef{\contentsname} if that's better for you. – Skillmon Jul 25 '17 at 19:13
• @Skillmon are you sure? – David Carlisle Jul 25 '17 at 19:50