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 RightToLeftConvert(string init_str, RightToLeftTextType type) { if (init_str.Contains(" ")) { throw new ArgumentException("This is not one word!"); } // TODO: before shaping maybe unshape initial string char[] dest = new char[init_str.Length]; int destLength = 0; switch (type) { case RightToLeftTextType.Arabic: destLength = ArabicLigaturizer.Arabic_Shape(init_str.ToCharArray(), 0, init_str.Length, dest, 0, 0, 0); break; case RightToLeftTextType.Hebrew: destLength = HebrewLigaturizer.Hebrew_Shape(init_str.ToCharArray(), 0, init_str.Length, dest, 0, 0, 0); break; } return(new string(dest, 0, destLength)); }
public static bool IsRightToLeftMark(char s) { if (HebrewLigaturizer.IsHebrewPoint(s) || HebrewLigaturizer.IsHebrewCantillationMark(s)) { return(true); } if (ArabicLigaturizer.IsArabicHonorific(s) || ArabicLigaturizer.IsArabicAnnotationSigns(s) || ArabicLigaturizer.IsArabicPoint(s) || ArabicLigaturizer.IsArabicMark(s)) { return(true); } return(false); }
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); }