Click here to Skip to main content
15,903,175 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I want to force controls in my application to show specific numbers digits

Example Image

I set the CurrentCulture in the main procedure; but it does not change the numbers digits ..

XML
<STAThread()>
   Public Shared Sub Main()

       CultureInfo.DefaultThreadCurrentCulture = New CultureInfo("en-US", False)
       CultureInfo.DefaultThreadCurrentUICulture = New CultureInfo("en-US", False)

       Thread.CurrentThread.CurrentCulture = New CultureInfo("en-US", False)
       Thread.CurrentThread.CurrentUICulture = New CultureInfo("en-US", False)

       Dim FrmM As New FrmMain
       Application.Run(FrmM)

   End Sub

so I want to know how can I do this ..
Posted
Updated 15-Jan-15 4:56am
v4
Comments
Sergey Alexandrovich Kryukov 15-Jan-15 15:31pm    
It won't work this way, just because "Arabic numerals" are... 123...
Please see my answer; you can easily solve this problem.
—SA

1 solution

Force? Wrong word, I would say. You just need to output what you want.
The problem you have is: all (is I'm not much mistaken) Arabic cultures and Urdu cultures use… "Arabic numerals" ("Indo-Arabic"), which are ironically… Western European 1234567890.

What you show is not directly supported by these cultures. Your are showing something more traditional which is sometimes called "Eastern Arabic numerals" which also have separate Urdu variant:
http://en.wikipedia.org/wiki/Arabic_numerals[^],
http://en.wikipedia.org/wiki/Eastern_Arabic_numerals[^].

So, what happened if you use appropriate culture codes. Nothing special. For example, for "Urdu (Islamic Respublic of Pakistan", "اُردو (پاکستان)", or "Arabic (Syria)", "العربية (سوريا)", you can have:
C#
using System.Globalization;

// ...

CultureInfo culture = new CultureInfo("ur-PK");
string result = 123.ToString(culture); // returns "123"!
culture = new CultureInfo("ar-SY");
result = 123.ToString(culture); // returns "123"!
As expected, no luck. I would expect the same from all other cultures using Perso-Arabic or Urdu.

So, you need your own solution, which is quite easy. Look at this code sample:
http://www.wenda.io/questions/637582/converting-numbers-from-western-arabic-digits-1-2-3-to-eastern-arabic-digit.html[^].

I hope you got the idea. All you need it to look up for "01…" location in Unicode tables. The order is the same, so the conversion is a simple shift. Please see:
http://unicode.org/charts/PDF/U0600.pdf[^], look at "Arabic-Indic digit zero", u0660.
With Urdu, the situation is different. "The Urdu numerals are currently assigned to the same locations as Farsi numerals": http://www.unicode.org/L2/L2000/00134-urdu-num.htm[^].

So, the code would be the same, and the strings will be the same. If you want to present those numerals differently, you will need to have slightly different fonts for Arab and Urdu.

—SA
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900