Decode bytes back to string : ASCIIEncoding « Internationalization I18N « VB.Net






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

1.ASCIIEncoding Class represents an ASCII character encoding of Unicode characters.
2.ASCIIEncoding Class Represents an ASCII character encoding of Unicode characters.
3.Get positions of the special characters
4.Create ASCIIEncoding class.
5.ASCIIEncoding.GetByteCount calculates the number of bytes produced by encoding a set of characters
6.ASCIIEncoding.GetByteCount (String)
7.Encodes characters from the specified character array into the specified byte array.
8.Encodes characters from the specified String into the specified byte array.
9.Calculates the number of characters produced by decoding bytes
10.Decodes bytes into the specified character array.
11.Calculates the maximum number of bytes produced by encoding the specified number of characters.
12.Calculates the maximum number of characters produced by decoding the specified number of bytes.
13.Decodes a range of bytes from a byte array into a string.