Decode bytes back to string
Imports System
Imports System.Text
Imports Microsoft.VisualBasic.Strings
Class ASCIIEncodingExample
Public Shared Sub Main()
Dim ascii As New ASCIIEncoding()
Dim unicodeString As String = "Pi:" & ChrW(928) & " Sigma:" & ChrW(931) & "."
Console.WriteLine(unicodeString)
Dim encodedBytes As Byte() = ascii.GetBytes(unicodeString)
Dim b As Byte
For Each b In encodedBytes
Console.Write("[{0}]", b)
Next b
Dim decodedString As String = ascii.GetString(encodedBytes)
Console.WriteLine(decodedString)
End Sub 'Main
End Class
Related examples in the same category