This artical is how to convert the English like 123456789 to ١٢٣٤٥٦٧٨٩٩٠
public string ConvertToEasternArabicNumerals(string input)
{
System.Text.UTF8Encoding utf8Encoder = new System.Text.UTF8Encoding();
System.Text.Decoder utf8Decoder = utf8Encoder.GetDecoder();
System.Text.StringBuilder convertedChars = new System.Text.StringBuilder();
char[] convertedChar = new char[1];
byte[] bytes = new byte[] { 217, 160 };
char[] inputCharArray = input.ToCharArray();
foreach (char c in inputCharArray)
{
if (char.IsDigit(c))
{
bytes[1] = Convert.ToByte(160 + char.GetNumericValue(c));
utf8Decoder.GetChars(bytes, 0, 2, convertedChar, 0);
convertedChars.Append(convertedChar[0]);
}
else
{
convertedChars.Append(c);
}
}
return convertedChars.ToString();
}
public string ConvertToEasternArabicNumerals(string input)
{
System.Text.UTF8Encoding utf8Encoder = new System.Text.UTF8Encoding();
System.Text.Decoder utf8Decoder = utf8Encoder.GetDecoder();
System.Text.StringBuilder convertedChars = new System.Text.StringBuilder();
char[] convertedChar = new char[1];
byte[] bytes = new byte[] { 217, 160 };
char[] inputCharArray = input.ToCharArray();
foreach (char c in inputCharArray)
{
if (char.IsDigit(c))
{
bytes[1] = Convert.ToByte(160 + char.GetNumericValue(c));
utf8Decoder.GetChars(bytes, 0, 2, convertedChar, 0);
convertedChars.Append(convertedChar[0]);
}
else
{
convertedChars.Append(c);
}
}
return convertedChars.ToString();
}
How to get back from arabic character into English number ?
ReplyDeletec# code
Deletestatic string ArabicToWestern(string input)
{
StringBuilder western = new StringBuilder();
foreach(char num in input)
{
western.Append(char.GetNumericValue(num));
}
return western.ToString();
}
try this code
ReplyDeletePrivate 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
thank you for anser my question
Deletei have try your code,
but the result like this :
٩/١٦/٢٠١٣
9-116-12013
with this code i can
DeletePublic Function balikeun(ByVal input As String) As String
Dim western As StringBuilder = New StringBuilder
For Each num As Char In input
' If num = "/" Then Continue For
If Not num = "/" Then western.Append(Char.GetNumericValue(num)) Else western.Append("/")
Next
Return western.ToString
End Function
Here also give some idea
ReplyDeletehttps://educationandintertainment.blogspot.com/2018/03/simple-way-to-convert-english-number-to.html