如何强制我的应用程序显示特定的数字位数 [英] How do I force my application to show specific numbers digits

查看:121
本文介绍了如何强制我的应用程序显示特定的数字位数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想强制我的应用程序中的控件显示特定的数字数字



示例图像



我在主程序中设置了CurrentCulture;但它不会改变数字数字..



 <   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。运行(FrmM)

结束子



所以我想知道我该怎么做..

解决方案

强制?我会说,错误的一句话。你只需要输出你想要的东西。

你遇到的问题是:所有(我没有太多错误)阿拉伯文化和乌尔都语文化使用......阿拉伯数字(印度 - 阿拉伯语 ),具有讽刺意味的是......西欧1234567890.



您所展示的内容并非直接受到这些文化的支持。您正在展示更传统的东西,有时也被称为东方阿拉伯数字,也有单独的乌尔都语变体:

http://en.wikipedia.org/wiki/Arabic_numerals [ ^ ],

http://en.wikipedia.org/wiki/Eastern_Arabic_numerals [ ^ ]。



所以,如果您使用适当的文化代码会发生什么。没什么特别的。例如,对于乌尔都语(巴基斯坦伊斯兰共和国,اردو(پاکستان)或阿拉伯语(叙利亚),العربية(سوريا),您可以拥有:

 使用 System.Globalization; 

// ...

CultureInfo culture = new CultureInfo( ur-PK);
string result = < span class =code-digit> 123 .ToString(culture); // 返回123 !
culture = new CultureInfo( ar-SY);
result = 123 .ToString(culture); // 返回123!

正如所料,没有我希望使用Perso-Arabic或Urdu的所有其他文化也一样。



所以,你需要自己的解决方案,这很容易。看看这个代码示例:

http://www.wenda.io/questions/637582/converting-numbers-from-western-arabic-digits-1-2-3-to-eastern-arabic- digit.html [ ^ ]。



我希望你明白了。所有你需要它来查找Unicode表中的01 ...位置。顺序是相同的,因此转换是一个简单的转变。请参阅:

http://unicode.org/charts/PDF/U0600.pdf [ ^ ],查看阿拉伯语 - 印度数字零,u0660。

乌尔都语的情况有所不同。 乌尔都语数字目前被分配到与波斯语数字相同的位置: http:// www。 unicode.org/L2/L2000/00134-urdu-num.htm [ ^ ]。



因此,代码将是相同的,字符串将是相同的。如果你想以不同的方式呈现这些数字,你需要为阿拉伯和乌尔都语提供稍微不同的字体。



-SA

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 ..

<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 ..

解决方案

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:

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


这篇关于如何强制我的应用程序显示特定的数字位数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆