My curiosity lies on mapping for transliteration. I am working on a project that uses transliteration. I have seen some solved code for this. But I could understand them. For example,
\def\tcmapto#1#2{\expandafter\def\csname tcmapto\number`#1\endcsname{#2}}
\def\tcmapnumto#1#2{\expandafter\def\csname tcmapto#1\endcsname{#2}}
\def\tcremap#1{\ifcsname tcmapto\number`#1\endcsname
\csname tcmapto\number`#1\endcsname\else#1\fi}
Question: How these three lines work part by part. Can anyone elaborate with patience. Thank you.
Complete code:
\documentclass{article}
\usepackage{tokcycle}
\def\tcmapto#1#2{\expandafter\def\csname tcmapto\number`#1\endcsname{#2}}
\def\tcmapnumto#1#2{\expandafter\def\csname tcmapto#1\endcsname{#2}}
\def\tcremap#1{\ifcsname tcmapto\number`#1\endcsname
\csname tcmapto\number`#1\endcsname\else#1\fi}
\tcmapto{ং}{n}% OR \tcmapnumto{2434}{n}
\tcmapto{আ}{Ā}% OR \tcmapnumto{2438}{Ā}
\tcmapto{ন}{n}% OR \tcmapnumto{2472}{n}
\tcmapto{ব}{b}% OR \tcmapnumto{2476}{b}
\tcmapto{ম}{m}% OR \tcmapnumto{2478}{m}
\tcmapto{র}{ra}% OR \tcmapnumto{2480}{ra}
\tcmapto{ল}{l}% OR \tcmapnumto{2482}{l}
\tcmapto{স}{s}% OR \tcmapnumto{2488}{s}
\tcmapto{া}{ā}% OR \tcmapnumto{2494}{ā}
\tcmapto{ো}{ō}% OR \tcmapnumto{2507}{ō}
\begin{document}
\Characterdirective{\addcytoks[x]{\tcremap{#1}}}
\tokencyclexpress
আমার সোনার বাংলা
আ-মা-র সো-না-র বাং-লা
\endtokencyclexpress
\end{document}
\tcremap, in turn. Group tokens are retained, while the tokens within the group are also processed individually through the cycle. – Steven B. Segletes Nov 10 '21 at 15:31