如何转换阿拉伯数字为int? [英] How to convert Arabic number to int?

查看:225
本文介绍了如何转换阿拉伯数字为int?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在C#中的项目,需要使用阿拉伯数字工作,但那么它必须存储为数据库整数,我需要一个解决方案,以阿拉伯数字转换成int类型C#。
的任何解决方案或帮助吗?
在此先感谢






从评论:



<块引用>

我有阿拉伯数字1,2,3,4 ...,必须转换为1,2,3,或234转换为234



解决方案

阿拉伯数字就像1,2,3,4的unicode编码为范围内的1632个字符1641。减去的Unicode从阿拉伯每个数字的Unicode值为零阿拉伯(1632)性格得到他们的数字值。其位值乘以每个数字值,总结的结果得到的整数。



或者使用 Regex.Replace 与阿拉伯数字的字符串转换为十进制数字组成的字符串,然后使用 Int.Parse 来的结果转换为整数。


I work on a project in C# which requires to use arabic numbers, but then it must store as integer in database, I need a solution to convert arabic numbers into int in C#. Any solution or help please? thanks in advance


From comments:

I have arabic numbers like ١،٢،٣،٤... and must convert to 1,2,3, or ٢٣٤ convert to 234

解决方案

Arabic digits like ١،٢،٣،٤ in unicode are encoded as characters in the range 1632 to 1641. Subtract the unicode for arabic zero (1632) from the unicode value of each arabic digit character to get their digital values. Multiply each digital value with its place value and sum the results to get the integer.

Alternatively use Regex.Replace to convert the string with Arabic digits into a string with decimal digits, then use Int.Parse to convert the result into an integer.

这篇关于如何转换阿拉伯数字为int?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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