Home > Uncategorized > #Visual #Transliteration from Russian in C#

#Visual #Transliteration from Russian in C#

1200x630bb

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;
}

Advertisements
Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: