how do i check whether my string contains arabic characters or not?
-
Thursday, August 21, 2008 6:18 AMhow do i check whether my string contains arabic characters or not?
All Replies
-
Thursday, August 21, 2008 9:46 AMModerator
Try this:
public static bool HasArabicGlyphs(string text) {
char[] glyphs = text.ToCharArray();
foreach (char glyph in glyphs) {
if (glyph >= 0x600 && glyph <= 0x6ff) return true;
if (glyph >= 0x750 && glyph <= 0x77f) return true;
if (glyph >= 0xfb50 && glyph <= 0xfc3f) return true;
if (glyph >= 0xfe70 && glyph <= 0xfefc) return true;
}
return false;
}
Hans Passant.- Marked As Answer by Dinesh Kumar Paramasivam Friday, August 22, 2008 7:03 AM
- Unmarked As Answer by Dinesh Kumar Paramasivam Friday, August 22, 2008 7:03 AM
- Marked As Answer by Dinesh Kumar Paramasivam Friday, August 22, 2008 7:03 AM
-
Friday, August 22, 2008 7:03 AMThanks for your help...It working now...
- Edited by Dinesh Kumar Paramasivam Friday, August 22, 2008 7:04 AM Spelling
-
Tuesday, July 06, 2010 8:19 AM
internal bool HasArabicCharacters(string text) { Regex regex = new Regex( "[\u0600-\u06ff]|[\u0750-\u077f]|[\ufb50-\ufc3f]|[\ufe70-\ufefc]"); return regex.IsMatch(text); }You can use the above method to check for Arabic characters using Regular Expressions.
Makhaly_cs- Proposed As Answer by Muhammad Makhaly Tuesday, July 06, 2010 8:19 AM

