如何使用C#.net在Windows窗体应用程序中计算Gujarati no? [英] How to calculate Gujarati no in Windows form application using C#.net?

查看:62
本文介绍了如何使用C#.net在Windows窗体应用程序中计算Gujarati no?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Guys,

我想使用c#.net开发Gujarati Windows表单应用程序。

但我有问题

1.计算古吉拉特语中的两个号码。

我通过此代码解决了

Hello Guys,
I want to Develope Gujarati Windows form application using c#.net.
But i have problem that
1. Calculation of two number in Gujarati.
I Solved by this code

public static double ParseValue(string value)
{
    return double.Parse(string.Join("",
        value.Select(c => "+-.".Contains(c)
           ? "" + c: "" + char.GetNumericValue(c)).ToArray()),
        NumberFormatInfo.InvariantInfo);
}





但此代码以英寸数值提供我。

但是当计算两个Guajarati no时,我得到英文输出。

赞了这个



But this Code Provide Me in Eng Numeric Value.
But When Calculate two Guajarati no, i get output in english.
Like This

 Label1.Text = (ParseValue(TextBox1.Text) + ParseValue(TextBox2.Text)).ToString();

//Output is Like this
// ૩ + ૬ = 9



那么我怎么能以古吉拉特语输出数字编号



2.什么是Microsoft Access中古吉拉特语值的数据类型。



数字,日期时间等..



请给我解决方案。


So How can i get output in Gujarati numeric No.

2. What is Data type for Gujarati Value in Microsoft Access.
For
Numeric, DateTime ETC..

Please Give Me Solution.

推荐答案

没有像古吉拉特语数字这样的东西。只有古吉拉特语数字

古吉拉特语字母 - 维基百科,免费百科全书 [ ^ ],

http://www.unicode.org/charts/PDF/U0A80.pdf [ ^ ]。



关于数字,那么不能是欧洲人,印度人或亚美尼亚人。数字是数学对象,它们不依赖于字母表。 (它们也不能是十进制或十六进制,与某些人的天真信仰形成对比。)



现在,请注意古吉拉特语数字映射到代码点按照我们在通常计算中使用的欧洲(西方阿拉伯语)数字的确切顺序;代码点域跨越0xAE6到0xAEF,而西方数字代码点0x30到0x39。也就是说,古吉拉特语数字的代码点可以通过将其移动0xAE6 - 0x30从相应的欧洲数字获得,反之亦然。



所以,这是一个想法:用数字执行所有计算,使用通常的算术,只显示古吉拉特语的结果。首先,使用西方格式创建一个字符串(使用诸如 int.ToString()之类的方法),然后将将每个字符移到Gujarati 域,如下所述以上。如果你需要解析古吉拉特语文本回西方数字域,以获得西方表示法中的数字,你可以使用相应的解析方法进一步解析,例如 int.TryParse int.Parse



您可能会问:如何从a转换。 NET字符(Unicode字符)到代码点(算术编号),反之亦然?这个问题并不像看起来那么微不足道;您需要了解Unicode的工作原理原则上,您可以使用这两个数字域位于BOM中并且.NET内部使用编码UTF-8LE的事实。这意味着你可以简单地将每个字符打字为 short 数字,反之亦然。 但这不是一种安全的正确方法。应该以一种从内部Unicode表示的知识中抽象出来的方式编写应用程序软件。相反,您可以使用方法 System.CharConvertFromUtf32 System.Char.ConvertToUtf32

Char.ConvertFromUtf32 Method(Int32)(System) [ ^ ],

Char.ConvertToUtf32方法(字符,字符)(系统) [ ^ ]。



需要一些解释。始终使用相同大小的单词表示任何代码点的唯一UTF编码是UTF-32,因为32位足以容纳所有字符。表示字符的32位 int 类型的数字在数字上等于字符的代码点。这就是为什么上面引用的MSDN帮助页面将这些数字称为代码点,请参阅。那些代表UTF-32字的32位整数与你在上面提到的移位算法中使用的代码点编号相同。



也许你需要阅读一下Unicode,用于理解我上面使用的概念和BOM之类的术语。请参阅:

常见问题 - UTF-8,UTF-16,UTF-32& BOM [ ^ ],

字节顺序标记 - 维基百科,免费百科全书 [ ^ ],

Unicode - 维基百科,免费的百科全书 [ ^ ],

代码点 - 维基百科,免费的百科全书 [ ^ ]。







我忘了提到我没有看到古吉拉特语符号如何处理另外4个字符:减号,分隔符,小数符号和科学记数符的指数符号;我不知道它是否全部适用,但可能你知道它应该是什么样子。你可以找到它并分别替换这些字符。另外,我假设数字的顺序与欧洲表示法相同,最低有效数字在右边 - 另请参见 Unicode中的数字 [ ^ ]。



-SA
There is no such thing as Gujarati numbers. There are only Gujarati digits:
Gujarati alphabet — Wikipedia, the free encyclopedia[^],
http://www.unicode.org/charts/PDF/U0A80.pdf[^].

As to the numbers, then cannot be European, or Indian, or Armenian. Numbers are mathematical objects, they don't depends on alphabet. (They also cannot be decimal or hexadecimal, in contrast to the naive belief of some.)

Now, pay attention that Gujarati digits are mapped to code points in exact some order as European (Western Arabic) digits we use in usual computing; the code point domain spans 0xAE6 to 0xAEF, while Western digits take code points 0x30 to 0x39. That is, a Gujarati digit's code point can be obtained from a corresponding European number by shifting it by 0xAE6 − 0x30, and visa versa.

So, here is the idea: perform all calculation with numbers, using usual arithmetic, only display results in Gujarati. First, make a string in Western format (using methods such as int.ToString()) and than shift each character to Gujarati domain, as explained above. If you need to parse Gujarati text back to Western digit domain, to obtain a number in Western notation, which you can further parse using corresponding parse methods, such as int.TryParse or int.Parse.

You may ask: how to convert from a .NET character (Unicode character) to a code point (arithmetic number) and visa versa? This question is not as trivial as it may seem; you need to understand how Unicode works In principle, you can use the fact that both numeral domains lie in BOM and that .NET internally uses the encoding UTF-8LE. It means that you can simply type-case each character to short number and visa versa. But this is not a safe correct way. Application software should be written in a way abstracted from the knowledge of internal Unicode representation. Instead, you can use the methods System.CharConvertFromUtf32 and System.Char.ConvertToUtf32:
Char.ConvertFromUtf32 Method (Int32) (System)[^],
Char.ConvertToUtf32 Method (Char, Char) (System)[^].

It needs some explanation. The only UTF encoding which always uses the same-size word for representing any code point is UTF-32, just because 32 bit is enough to hold all characters. The numbers of the 32-bit int type representing characters are numerically equal to character's code point. That's why the MSDN help page referenced above call those numbers "code points", please see. Those 32-bit integers representing UTF-32 words is the same code point numbers you will use in the shift arithmetic referenced above.

Perhaps you need to read a bit on Unicode, to understand the concepts I used above and terms like "BOM". Please see:
FAQ — UTF-8, UTF-16, UTF-32 & BOM[^],
Byte order mark — Wikipedia, the free encyclopedia[^],
Unicode — Wikipedia, the free encyclopedia[^],
Code point — Wikipedia, the free encyclopedia[^].



I forgot to mention that I did not check out how Gujarati notation deals with 4 more characters: minus sign, separator, decimal sign and exponent sign for scientific notation; I don't know if it is all applicable, but probably you know how it should look. You can find it out and replace these characters separately. Also, I assumed that the order of digits is the same as in European notation, least significant digit being on the right — see also Numerals in Unicode[^].

—SA


这篇关于如何使用C#.net在Windows窗体应用程序中计算Gujarati no?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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