Last Updated: February 25, 2016
·
1.405K
· marwan

Ignore Tashkeel (Diacritics ) when comparing arabic string values

string str1 = "الْحَمْدُ لِلَّهِ رَبِّ الْعَالَمِينَ";
string str2 = "الحمد لله رب العالمين";

var arabicCulture = new CultureInfo("ar");
int result1 = arabicCulture.CompareInfo.Compare(str1, str2, CompareOptions.IgnoreNonSpace); // output: 0 (strings are equal)
var result2 = arabicCulture.CompareInfo.IndexOf(str1, "العالمين", CompareOptions.IgnoreNonSpace); // output 24