The 'full' .NET Framework contains the property NumberFormatInfo.DigitSubstitution
. If you were developing in .NET, this would be the property you would use if you wanted numbers to be formatted using Arabic-Indic digits. However, this property isn't available in the Windows Phone version of the framework.
If a property or method exists in the full .NET Framework but not in Windows Phone, this is normally an indication that the functionality isn't in the Windows Phone version of the framework. As a result you will have to do the conversion of numbers to strings using Arabic-Indic digits yourself.
It's possible to write a conversion method that converts a number to a string using Latin digits, and then replaces the Latin digits with Arabic-Indic digits, for example:
private const char LatinDigitZero = '0';
private const char ArabicIndicDigitZero = '\u0660';
public static string ConvertToArabicIndicString(int number)
{
string result = string.Format("{0:d}", number);
for (int digit = 0; digit <= 9; ++digit)
{
result = result.Replace((char)(LatinDigitZero + digit), (char)(ArabicIndicDigitZero + digit));
}
return result;
}
This could easily be adapted to take a CultureInfo
object as an additional parameter.
This uses the fact that the Arabic-Indic digits corresponding to the Latin digits 0 to 9 are Unicode characters \u0660
to \u0669
, respectively.
I gave this a quick test and as far as I could tell it worked. However, I'm not at all fluent in any language that uses Arabic-Indic digits so I can't say whether this method converts the number to a string correctly. In particular, I don't know whether this method generates a number with the digits in the right order or handles negative numbers correctly. Hopefully, any necessary such modifications should be easy for you to make.