I need to display an english double in arabic numerical characters for an application I am working on.
Here is an example class that holds the double:
I've found a very quick and easy solution to this. I discovered that the use of arabic characters for numbers was contextual; ie the digit shape depends on the previous text in the same output.
Example: Entering "1234" as the text in a TextBlock element would simply display this in the english shape. However, if 1234 was preceded with some arabic text (let's say "abcde") such as شلاؤيث1234. In this example, then first four digits would be in the arabic shapes for the characters "1234". (Note: this doesn't seem to work in for this website - displays correctly in the text box however the preview shows english shapes for the numbers)
See these links for more information:
http://msdn.microsoft.com/en-us/library/system.globalization.numberformatinfo.digitsubstitution.aspx http://msdn.microsoft.com/en-us/library/system.globalization.digitshapes.aspx
From looking at the second link, the obvious choice I wanted was NativeNational, however since our CurrentCulture is set automatically by the operating system, the CurrentCulture instance is read only.
To by pass this, I simply created a new CultureInfo object and changed the DigitSubstitution to DigitShapes.NativeNational:
CultureInfo ci = CultureInfo.CreateSpecificCulture(Thread.CurrentThread.CurrentCulture.Name);
ci.NumberFormat.DigitSubstitution = DigitShapes.NativeNational;
Thread.CurrentThread.CurrentCulture = ci;
This looks like it does what you need:
http://weblogs.asp.net/abdullaabdelhaq/archive/2009/06/27/displaying-arabic-number.aspx