stenobot
stenobot

Reputation: 323

Convert int to Arabic number string in UWP

I'm trying to use String.Format to convert an integer into a string, but I need the number to reflect the current culture for languages with classical shapes (such as Arabic and Thai). This was previously possible in WPF, but UWP seems to be missing DigitShapes (even though System.Globalization.CultureInfo.CurrentCulture is still available). Anyone know a workaround for this in UWP?

Upvotes: 0

Views: 261

Answers (1)

stenobot
stenobot

Reputation: 323

I think I found a solution. The NumeralSystemTranslator class is supported in UWP. It's not as easy as I was hoping, but if you set the NumeralSystemTranslator.NumeralSystem property manually (it's Latin by default), it will return the native characters for numbers for the locale you specify. The List of values is here.

So, for Arabic, you'd do:

NumeralSystemTranslator translator = new NumeralSystemTranslator();
translator.NumeralSystem = "Arab";
string output = translator.TranslateNumerals("5");

Took me a while to track this down. Hope it's helpful to someone else as well :)

Upvotes: 1

Related Questions