using System; using ArabicSupport; namespace UPersian.Utils { public static class UPersianUtils { public static string RtlFix(this string str) { for (int i = 0; i < 10; i++) { str = str.Replace(i.ToString()[0], UPersianUtils._persianNumbers[i]); } str = str.Replace('ی', 'ﻱ'); str = str.Replace('ک', 'ﻙ'); str = ArabicFixer.Fix(str, false, false); str = str.Replace('ﺃ', 'آ'); return str; } public static bool IsRtl(this string str) { bool result = false; foreach (char c in str) { if ((c >= '؀' && c <= 'ۿ') || (c >= 'ﹰ' && c <= '')) { result = true; break; } } return result; } private static readonly char[] _persianNumbers = new char[] { '۰', '١', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹' }; } }