Beispiel #1
0
        /// <summary>
        /// Method Transliteration
        /// Makes transliteration depending on the type of alphabet.
        /// </summary>
        /// <param name="receivedString">String, which was inputed<</param>
        /// <returns>Transliterated string.</returns>
        public string Transliteration(string receivedString)
        {
            TypeOfText typeOfString         = GetTypeOfString(receivedString.ToLower());
            string     transliteratedString = CyrillicLatinTransliteration(receivedString, typeOfString);

            return(transliteratedString);
        }
Beispiel #2
0
        /// <summary>
        /// Method CyrillicLatinTransliteration
        /// Transliterates Cyrillic into Latin or Latin into Cyrillic, depending on the type of string.
        /// </summary>
        /// <returns>Transliterated string</returns>
        private string CyrillicLatinTransliteration(string receivedString, TypeOfText typeOfString)
        {
            StringBuilder transliteratedString = new StringBuilder();

            if (typeOfString == TypeOfText.Cyrillic)
            {
                foreach (var i in receivedString)
                {
                    if (char.IsLetter(i))
                    {
                        transliteratedString.Append(cyrillicLatinDictionary[i.ToString().ToLower()]);
                    }
                    else
                    {
                        transliteratedString.Append(i);
                    }
                }
            }

            if (typeOfString == TypeOfText.Latin)
            {
                foreach (var i in receivedString)
                {
                    if (char.IsLetter(i))
                    {
                        transliteratedString.Append(latinCyrillicDictionary[i.ToString().ToLower()]);
                    }
                    else
                    {
                        transliteratedString.Append(i);
                    }
                }
            }

            return(transliteratedString.ToString());
        }
Beispiel #3
0
 public void SetTypeOfText(TypeOfText type)
 {
     m_textType = type;
 }
Beispiel #4
0
 public void PushText(string text, TypeOfText type)
 {
     SetTypeOfText(type);
     PushText(text);
 }