gpt4 book ai didi

vb.net - 将阿拉伯数字转换成英文

转载 作者:行者123 更新时间:2023-12-05 00:35:07 24 4
gpt4 key购买 nike

我正在寻找一种将阿拉伯数字字符串“٠١٢٣٤٥٦٧٨٩”转换为英语的方法
数字字符串“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

最佳答案

您正在寻找 GetNumericValue char的方法将任何数字 Unicode 字符转换为 double 的类型。例如:

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();
}

根据您的需要进行修改。

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

关于vb.net - 将阿拉伯数字转换成英文,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9785713/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com