If any of you is developing Asp.net for the Middle East or in Arabic language in general, one cosmetic feature is to write the numbers in Eastern Arabic numerals. If you don't know what I mean you can visit this page
http://en.wikipedia.org/wiki/Eastern_Arabic_numerals
Here is a little code snippet for a static class that takes the string containing the numbers as an input and uses regular expressions to make the appropriate replacements after which it sends the output with the correct numerals. I hope somebody finds it
useful.
public static class ArabicNumbers
{
//Array containing the Eastern Numerals from 0 to 9
return Regex.Replace(input,"\\d", new MatchEvaluator(Entity));
}
}
By the way the above code can be used with any other numbering format, just get the HTML entities of the numbers from 0 to 9 and put them in ArabiHTML string array (of course you might then think of a new name for the array).
Let me know if this code is useful and of course any suggestions / enhancements are welcome.
abohmeed
Member
26 Points
18 Posts
Convert Arabic numbers to their Eastern Arabic numerals equivalent
Dec 13, 2010 04:34 PM|LINK
Hello all and merry Christmas
If any of you is developing Asp.net for the Middle East or in Arabic language in general, one cosmetic feature is to write the numbers in Eastern Arabic numerals. If you don't know what I mean you can visit this page http://en.wikipedia.org/wiki/Eastern_Arabic_numerals
Here is a little code snippet for a static class that takes the string containing the numbers as an input and uses regular expressions to make the appropriate replacements after which it sends the output with the correct numerals. I hope somebody finds it useful.
public static class ArabicNumbers
{
//Array containing the Eastern Numerals from 0 to 9
private static string[] ArabicHTML = {"٠","١","٢","٣","٤","٥","٦","٧","٨","٩" };
private static string Entity(Match m)
{
return ArabicHTML[int.Parse(m.Value)];
}
public static string Convert(string input)
{
return Regex.Replace(input,"\\d", new MatchEvaluator(Entity));
}
}
By the way the above code can be used with any other numbering format, just get the HTML entities of the numbers from 0 to 9 and put them in ArabiHTML string array (of course you might then think of a new name for the array).
Let me know if this code is useful and of course any suggestions / enhancements are welcome.