Hi ghonadr,
Refer the below sample code.
Here there is a problem of renderer the persian text. Windows text rendering engine becomes confused after getting persian characters and continues to append following text in RTL order. Thus we need to help renderer to proper render appended text in LTR order. For that we can append Unicode Left-to-right symbol U+200E after text.
HTML
<asp:Label ID="lblText" runat="server" />
C#
protected void Page_Load(object sender, EventArgs e)
{
string text = "9/1/37/1438/ج";
List<string> arrayList = new List<string>();
for (int i = text.Split('/').Length; i > 0; i--)
{
arrayList.Add(ToPersianNumber(text.Split('/')[i - 1]) + "\x200E");
}
lblText.Text = string.Join("/", arrayList);
}
private string ToPersianNumber(string input)
{
string[] persian = new string[10] { "۰", "۱", "۲", "۳", "۴", "۵", "۶", "۷", "۸", "۹" };
for (int j = 0; j < persian.Length; j++)
{
input = input.Replace(j.ToString(), persian[j]);
}
return input;
}
VB.Net
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
Dim text As String = "9/1/37/1438/ج"
Dim arrayList As New List(Of String)()
For i As Integer = text.Split("/"c).Length To 1 Step -1
arrayList.Add(ToPersianNumber(text.Split("/"c)(i - 1)) + "")
Next
lblText.Text = String.Join("/", arrayList)
End Sub
Private Function ToPersianNumber(input As String) As String
Dim persian As String() = New String(9) {"۰", "۱", "۲", "۳", "۴", "۵", "۶", "۷", "۸", "۹"}
For j As Integer = 0 To persian.Length - 1
input = input.Replace(j.ToString(), persian(j))
Next
Return input
End Function
Input
9/1/37/1438/ج
Output
ج/۱۴۳۸/۳۷/۱/۹