public static RightToLeftTextType GetRightToLeftTextType(string str) { string splitters = GetSplittersInThatString(str); string[] str_array = str.Split(splitters.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < str_array.Length; ++i) { if (str_array[i].Equals(string.Empty)) { continue; } if (ArabicLigaturizer.IsArabic(str_array[i][0])) { return(RightToLeftTextType.Arabic); } if (HebrewLigaturizer.IsHebrew((str_array[i][0]))) { return(RightToLeftTextType.Hebrew); } } return(RightToLeftTextType.None); }
public static string GetAppropriateFormWord(string word) { if (word.Length == 0) { return(word); } string ret_word = word; char s = word[0]; if (!HebrewLigaturizer.IsHebrew(s) && !ArabicLigaturizer.IsArabic(s)) { return(ret_word); } if (HebrewLigaturizer.IsHebrew(s)) { ret_word = Normalizer.RightToLeftConvert(word, RightToLeftTextType.Hebrew); } else if (ArabicLigaturizer.IsArabic(s)) { ret_word = Normalizer.RightToLeftConvert(word, RightToLeftTextType.Arabic); } if (!ret_word.Equals(word)) { string norm_word = word.Normalize(NormalizationForm.FormKD); string norm_ret_word = ret_word.Normalize(NormalizationForm.FormKD); if (norm_ret_word != norm_word) { // throw new Exception("Exception at the string normalization process."); return(word); } } return(ret_word); }