Decodes bytes into the specified character array. : ASCIIEncoding « Internationalization I18N « VB.Net






Decodes bytes into the specified character array.

 

Imports System
Imports System.Text

Class ASCIIEncodingExample
    Public Shared Sub Main()
        Dim chars() As Char
        Dim bytes() As Byte = {110,  99, 111, 100, 105, 110, 103,32,  69, 120,  97, 109, 112, 108, 101}

        Dim ascii As New ASCIIEncoding()

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

        Console.WriteLine("{0} characters used to decode bytes.", charsDecodedCount)

        Console.Write("Decoded chars: ")
        Dim c As Char
        For Each c In chars
            Console.Write("[{0}]", c)
        Next c
        Console.WriteLine()
    End Sub
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.Decode bytes back to string
4.Get positions of the special characters
5.Create ASCIIEncoding class.
6.ASCIIEncoding.GetByteCount calculates the number of bytes produced by encoding a set of characters
7.ASCIIEncoding.GetByteCount (String)
8.Encodes characters from the specified character array into the specified byte array.
9.Encodes characters from the specified String into the specified byte array.
10.Calculates the number of characters produced by decoding bytes
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.