Unicode utf-8 conversion to vb.net

tirupati.mullick

New member
Joined
Oct 17, 2006
Messages
1
Programming Experience
Beginner
My Problem is to show the arabic string in vb.net...

Basically we are importing the data from MySql to Access...
The arbic strings are converted perfectly into unicode utf-8 format...

for eg: '&# 1605;&# 1581;&# 1605;&# 1583; &# 1593;&# 1576;&# 1583;&# 1575;&# 1604;&# 1604;&# 1607; &# 1575;&# 1604;&# 1593;&# 1578;&# 1605;&# 1577;'

these unicodes are in number.. but vb.net uses its equivalent Hexadecimal codes
like

& #1605; = &H645
& #1581; = &H62D
& #1605; = &H645
etc....

and the hexadecimal displays fine in vb.net...

Is there is any code/syntax in vb.net to convert the unicodes number(& #1605; & #1581; & #1605;.....)
directly into arabic string....???


waiting for reply....
 
Last edited:
You can use the Convert.ToChar method to convert a single Unicode value to a single Char. As far as I'm aware there is no way to do it for multiple values in a single method call. You could write a method that took the Unicode values, converted them to Chars and then created a string, e.g.
VB.NET:
Public Function GetStringFromUnicode(ByVal ParamArray codes As Integer()) As String
    Dim bldr As New System.Text.StringBuilder

    For Each code As Integer In codes
        bldr.Append(Convert.ToChar(code))
    Next code

    Return bldr.ToString()
End Function
You can then call it like this:
VB.NET:
Dim myString As String = GetStringFromUnicode(1605, 1581, 1605, 1583, ...)
or like this:
VB.NET:
Dim codes As Integer() = {1605, 1581, 1605, 1583, ...}
Dim myString As String = GetStringFromUnicode(codes)
 
Back
Top