Sunday, June 13, 2010

Displaying Arabic Number. VB.Net

Displaying Arabic Number.


Imports System.Text

Private Sub Button1_Click
(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Label1.Text = TextBox1.Text
Label3.Text = ConvertToArabicNumerals(TextBox1.Text)


End Sub



Public Function ConvertToArabicNumerals(ByVal input As String) As String


Dim utf8Encoder As System.Text.UTF8Encoding = New UTF8Encoding()

Dim utf8Decoder As System.Text.Decoder = utf8Encoder.GetDecoder()

Dim convertedChars As New System.Text.StringBuilder()

Dim convertedChar As Char() = New Char(0) {}

Dim bytes As Byte() = New Byte() {217, 160}

Dim inputCharArray As Char() = input.ToCharArray()

For Each c As Char In inputCharArray


If Char.IsDigit(c) Then


bytes(1) = Convert.ToByte(160 + Char.GetNumericValue(c))

utf8Decoder.GetChars(bytes, 0, 2, convertedChar, 0)


convertedChars.Append(convertedChar(0))
Else

convertedChars.Append(c)

End If
Next

Return convertedChars.ToString()

End Function

3 comments:

  1. hi Asma
    Your arabic conversion helped me a lot
    How to do the vice versa?
    thanks
    Nithin

    ReplyDelete
  2. Hi Dude how to use this code in motorolo windows ce device (device series mk4000) ??? i didnt get any error...but arabic font not display in the device ...

    ReplyDelete
  3. You can download the Code from the below link

    http://drive.google.com/uc?id=0B5Aqxd0QER32amFYcW9MN1pkcTg&e=download

    ReplyDelete