Reputation: 31
I am building a culture specific .NET windows application and recently I faced a problem with the number shape which changed according to the OS culture. for example if the OS culture is English (United States) and run the application, the displayed numbers will be in english shape (the usual one we used to), but if I changed the windows culture to Arabic-SaudiArabia the numbers will be shown in different shape.
I want to force this application to display numbers in the english shape only whatever the culture is.
I searched the internet and tired many solutions which try to change the application Culture and UICulture without any result.
regards,
Upvotes: 2
Views: 600
Reputation: 46
use below code in behind code:
CultureInfo ci = CultureInfo.CreateSpecificCulture(Thread.CurrentThread.CurrentCulture.Name);
ci.NumberFormat.DigitSubstitution = DigitShapes.None;
Thread.CurrentThread.CurrentCulture = ci;
Upvotes: 1
Reputation: 1
Change it in registry directly.
Like that for English shape:
Microsoft.Win32.Registry.SetValue("HKEY_CURRENT_USER\Control Panel\International", "sNativeDigits", "0123456789")
For Arabic shape:
Microsoft.Win32.Registry.SetValue("HKEY_CURRENT_USER\Control Panel\International", "sNativeDigits", "٠١٢٣٤٥٦٧٨٩")
Microsoft.Win32.Registry.SetValue("HKEY_CURRENT_USER\Control Panel\International", "NumShape", "2")
Upvotes: 0
Reputation: 8664
You can specify the culture to use when doing your string conversion, e.g:
Dim i As Integer = 5
Dim s As String = i.ToString(CultureInfo.InvariantCulture)
Upvotes: 1
Reputation: 17931
Try
culture.NumberFormat.DigitSubstitution=System.Globalization.DigitShapes.None;
Upvotes: 0