将阿拉伯数字转换成英文 [英] convert Arabic numerical to English
本文介绍了将阿拉伯数字转换成英文的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在寻找一种将阿拉伯数字字符串٠١٢٣٤٥٦٧٨٩"转换为英语的方法数字字符串0123456789"
i am looking for a way to convert the Arabic numerical string "٠١٢٣٤٥٦٧٨٩" to an English numerical string "0123456789"
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
dim Anum as string ="٠١٢٣٤٥٦٧٨٩"
dim Enum as string =get_egnlishNum(Anum)
End Sub
private function get_egnlishNum(byval _Anum as string) as string
'' converting code
end function
推荐答案
您正在寻找 char
类型的 GetNumericValue
方法,该方法将任何数字 Unicode 字符转换为一个双.例如:
You're looking for the GetNumericValue
method of the char
type which converts any numeric Unicode character to a double. For example:
double two = char.GetNumericValue('٢');
Console.WriteLine(two); // prints 2
例如:
static string ArabicToWestern(string input)
{
StringBuilder western = new StringBuilder();
foreach(char num in input)
{
western.Append(char.GetNumericValue(num));
}
return western.ToString();
}
根据您的需要进行修改.
Modify per your needs.
VB.NET:
Private Shared Function ArabicToWestern(ByVal input As String) As String
Dim western As StringBuilder = New StringBuilder
For Each num As Char In input
western.Append(Char.GetNumericValue(num))
Next
Return western.ToString
End Function
这篇关于将阿拉伯数字转换成英文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文