.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

VBNET function to convert charset encoding to windows-1256

0 REPLIES 0
Reply
Message 1 of 1
bazbomb
727 Views, 0 Replies

VBNET function to convert charset encoding to windows-1256

am looking for simple vb.net function to convert text to windows-1256.

 

For example the below text :

 

ßáãÉ ÇáãÑßÒ 
when I try to convert it to proper Arabic language I used the online tool http://iosart.com/tools/charset-fixer then choosed Arabic(windows-1256).
I used the below function with no use : 

Public Function ConvertUTF8StringEncoding(ByVal StringToConvert As String, Optional ByVal TargetCharSet As String = "windows-1256") As Byte()
Dim ByteConvertedString() As Byte
Dim ByteStringToConvert() As Byte
Dim TargetEncoding As Encoding
' Convert the string to a Byte array
ByteStringToConvert = Encoding.UTF8.GetBytes(StringToConvert.ToCharArray)
' Get the target encoding type
TargetEncoding = Encoding.GetEncoding(TargetCharSet)
' Convert the byte array using the target encoding
ByteConvertedString = Encoding.Convert(System.Text.Encoding.UTF8, TargetEncoding, ByteStringToConvert)
Return ByteConvertedString
End Function

Private Function BinaryUTF8ToString(ByVal Binary() As Byte) As String
Return System.Text.UnicodeEncoding.UTF8.GetString(Binary)
End Function

 

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim stringConvertedString As String = BinaryUTF8ToString(ConvertUTF8StringEncoding("ßáãÉ ÇáãÑßÒ "))

lbresult.Text = stringConvertedString
End Sub

 

 
Tags (1)
0 REPLIES 0

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost