Click here to Skip to main content
14,736,767 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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);
}


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

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.
Posted
Updated 29-Jan-16 21:27pm
v4

1 solution

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[^].

[EDIT]

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
   
v3

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