#Visual #Transliteration from Russian in C#
Transliteration is where you convert one alphabet into another while maintaining the phonetics in as much as possible.
Visual Transliteration is much more niche, and it about maintaining the visual representation of one alphabet in another, for example “Н” in Russian is pronounced “N”, but looks visually identical to a Latin “H”.
This code is for VISUAL transliteration, and NOT audible transliteration.
private static string VisualTransliterate(string russian)
{
var map = new Dictionary<string, string>
{
{“а”, “a”},
{“б”, “b”},
{“в”, “B”},
{“г”, “r”},
{“д”, “A”},
{“е”, “e”},
{“ё”, “e”},
{“ж”, “x”},
{“з”, “3”},
{“и”, “N”},
{“й”, “N”},
{“к”, “k”},
{“л”, “n”},
{“м”, “M”},
{“н”, “H”},
{“о”, “o”},
{“п”, “n”},
{“р”, “p”},
{“с”, “c”},
{“т”, “T”},
{“у”, “y”},
{“ф”, “o”},
{“х”, “x”},
{“ц”, “u”},
{“ч”, “u”},
{“ш”, “w”},
{“щ”, “w”},
{“ъ”, “b”},
{“ы”, “b”},
{“ь”, “b”},
{“э”, “3”},
{“ю”, “H”},
{“я”, “R”},
{“А”, “A”},
{“Б”, “B”},
{“В”, “B”},
{“Г”, “R”},
{“Д”, “A”},
{“Е”, “E”},
{“Ё”, “E”},
{“Ж”, “X”},
{“З”, “3”},
{“И”, “N”},
{“Й”, “N”},
{“К”, “K”},
{“Л”, “N”},
{“М”, “M”},
{“Н”, “H”},
{“О”, “O”},
{“П”, “N”},
{“Р”, “P”},
{“С”, “C”},
{“Т”, “T”},
{“У”, “Y”},
{“Ф”, “O”},
{“Х”, “X”},
{“Ц”, “U”},
{“Ч”, “Y”},
{“Ш”, “W”},
{“Щ”, “W”},
{“Ъ”, “b”},
{“Ы”, “b”},
{“Ь”, “b”},
{“Э”, “3”},
{“Ю”, “H”},
{“Я”, “R”}
};
var strOutput = “”;
foreach (var c in russian)
{
if (map.ContainsKey(c.ToString()))
{
strOutput += map[c.ToString()];
}
else
{
strOutput += c.ToString();
}
}
return strOutput;
}