Decodes a sequence of bytes from the specified byte array : Decoder « Development « VB.Net






Decodes a sequence of bytes from the specified byte array

 
Imports System
Imports System.Text

Class UnicodeEncodingExample

    Public Shared Sub Main()
        Dim chars() As Char
        Dim bytes() As Byte = {86, 0, 11, 0, 103, 0, 99, 0, 111, 0, 111, 0, 101, 0}

        Dim uniDecoder As Decoder = Encoding.Unicode.GetDecoder()

        Dim charCount As Integer = uniDecoder.GetCharCount(bytes, 0, bytes.Length)
        chars = New Char(charCount - 1) {}
        Dim charsDecodedCount As Integer = uniDecoder.GetChars(bytes, 0, bytes.Length, chars, 0)

        Dim c As Char
        For Each c In  chars
            Console.Write("[{0}]", c)
        Next c
    End Sub
End Class

   
  








Related examples in the same category

1.Decoder Class converts a sequence of encoded bytes into a set of characters.
2.Create Decoder class.
3.Decoder.GetCharCount calculates the number of characters produced by decoding a sequence of bytes