using System.Collections.Generic; namespace RMuseum.Services.Implementation.ImportedFromDesktopDiwan { /// /// Persian specific text utility class /// public class GPersianTextSync { /// /// convert persian text to simple pinglish /// /// /// public static string Farglisize(string inputStr) { string outStr = ""; string s; foreach (char c in inputStr) if (_PinglishDic.TryGetValue(c, out s)) outStr += s; return outStr; } /// /// equaivalnet for persian characters /// private static Dictionary _PinglishDic = new Dictionary() { {'ا', "a"}, {'آ', "a"}, {'ب', "b"}, {'پ', "p"}, {'ت', "t"}, {'ث', "s"}, {'ج', "j"}, {'چ', "ch"}, {'ح', "h"}, {'خ', "kh"}, {'د', "d"}, {'ذ', "z"}, {'ر', "r"}, {'ز', "z"}, {'ژ', "zh"}, {'س', "s"}, {'ش', "sh"}, {'ص', "s"}, {'ض', "z"}, {'ط', "t"}, {'ظ', "z"}, {'ع', "E"}, {'غ', "gh"}, {'ف', "f"}, {'ق', "gh"}, {'ک', "k"}, {'گ', "g"}, {'ل', "l"}, {'م', "m"}, {'ن', "n"}, {'ه', "h"}, {'و', "v"}, {'ی', "i"}, {'ئ', "E"}, {'أ', "A"}, {'إ', "E"}, {' ', "-"}, }; public static string UniquelyFarglisize(string inputStr) { string outStr = ""; string s; foreach (char c in inputStr) if (_UniqueAlphaNames.TryGetValue(c, out s)) outStr += s; return outStr; } private static Dictionary _UniqueAlphaNames = new Dictionary() { {'ا', "a"}, {'آ', "a"}, {'ب', "b"}, {'پ', "p"}, {'ت', "t"}, {'ث', "th"}, {'ج', "j"}, {'چ', "ch"}, {'ح', "hh"}, {'خ', "kh"}, {'د', "d"}, {'ذ', "the"}, {'ر', "r"}, {'ز', "z"}, {'س', "si"}, {'ش', "sh"}, {'ط', "tt"}, {'ظ', "zz"}, {'ص', "ss"}, {'ض', "zzz"}, {'ع', "e"}, {'غ', "gh2"}, {'ف', "f"}, {'ق', "gh"}, {'ک', "k"}, {'گ', "g"}, {'ل', "l"}, {'م', "m"}, {'ن', "n"}, {'ه', "h"}, {'و', "v"}, {'ی', "y"}, }; } }