Created
April 8, 2020 08:41
-
-
Save milovidov983/ab13405fee3e1c8e24fda1e03d73f9bd to your computer and use it in GitHub Desktop.
cyrilic map
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class StringUtil { | |
private static Dictionary<char, string> iso = new Dictionary<char, string>(); //ISO 9-95 | |
public static string Translit(this string str) { | |
var translitedCollection = str.Select(cyrilicSymbol => { | |
if (iso.TryGetValue(cyrilicSymbol, out var translitedSymbol)) { | |
return translitedSymbol; | |
} | |
return cyrilicSymbol.ToString(); | |
}); | |
return string.Join("", translitedCollection); | |
} | |
static StringUtil() { | |
iso.Add('Є', "YE"); | |
iso.Add('І', "I"); | |
iso.Add('Г', "G"); | |
iso.Add('і', "i"); | |
iso.Add('№', "#"); | |
iso.Add('є', "ye"); | |
iso.Add('ѓ', "g"); | |
iso.Add('А', "A"); | |
iso.Add('Б', "B"); | |
iso.Add('В', "V"); | |
iso.Add('Г', "G"); | |
iso.Add('Д', "D"); | |
iso.Add('Е', "E"); | |
iso.Add('Ё', "YO"); | |
iso.Add('Ж', "ZH"); | |
iso.Add('З', "Z"); | |
iso.Add('И', "I"); | |
iso.Add('Й', "J"); | |
iso.Add('К', "K"); | |
iso.Add('Л', "L"); | |
iso.Add('М', "M"); | |
iso.Add('Н', "N"); | |
iso.Add('О', "O"); | |
iso.Add('П', "P"); | |
iso.Add('Р', "R"); | |
iso.Add('С', "S"); | |
iso.Add('Т', "T"); | |
iso.Add('У', "U"); | |
iso.Add('Ф', "F"); | |
iso.Add('Х', "X"); | |
iso.Add('Ц', "C"); | |
iso.Add('Ч', "CH"); | |
iso.Add('Ш', "SH"); | |
iso.Add('Щ', "SHH"); | |
iso.Add('Ъ', "'"); | |
iso.Add('Ы', "Y"); | |
iso.Add('Ь', ""); | |
iso.Add('Э', "E"); | |
iso.Add('Ю', "YU"); | |
iso.Add('Я', "YA"); | |
iso.Add('а', "a"); | |
iso.Add('б', "b"); | |
iso.Add('в', "v"); | |
iso.Add('г', "g"); | |
iso.Add('д', "d"); | |
iso.Add('е', "e"); | |
iso.Add('ё', "yo"); | |
iso.Add('ж', "zh"); | |
iso.Add('з', "z"); | |
iso.Add('и', "i"); | |
iso.Add('й', "j"); | |
iso.Add('к', "k"); | |
iso.Add('л', "l"); | |
iso.Add('м', "m"); | |
iso.Add('н', "n"); | |
iso.Add('о', "o"); | |
iso.Add('п', "p"); | |
iso.Add('р', "r"); | |
iso.Add('с', "s"); | |
iso.Add('т', "t"); | |
iso.Add('у', "u"); | |
iso.Add('ф', "f"); | |
iso.Add('х', "x"); | |
iso.Add('ц', "c"); | |
iso.Add('ч', "ch"); | |
iso.Add('ш', "sh"); | |
iso.Add('щ', "shh"); | |
iso.Add('ъ', ""); | |
iso.Add('ы', "y"); | |
iso.Add('ь', ""); | |
iso.Add('э', "e"); | |
iso.Add('ю', "yu"); | |
iso.Add('я', "ya"); | |
iso.Add('«', ""); | |
iso.Add('»', ""); | |
iso.Add('—', "-"); | |
iso.Add(' ', "-"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment