Encoder Class converts a set of characters into a sequence of bytes.
Imports System
Imports System.Text
Imports Microsoft.VisualBasic
Imports Microsoft.VisualBasic.Strings
Class EncoderTest
Public Shared Sub Main()
' ChrW(928) = Pi, ChrW(931) = Sigma
Dim chars() As Char = {ChrW(928), ChrW(931)}
' Encode characters using an Encoding object.
Dim encoding As Encoding = Encoding.UTF7
' Encode complete array for comparison.
Dim allCharactersFromEncoding As Byte() = encoding.GetBytes(chars)
Console.WriteLine("All characters encoded:")
ShowArray(allCharactersFromEncoding)
End Sub 'Main
Public Shared Sub ShowArray(theArray As Array)
Dim o As Object
For Each o In theArray
Console.Write("[{0}]", o)
Next o
Console.WriteLine(ControlChars.NewLine)
End Sub 'ShowArray
End Class 'EncoderTest
Related examples in the same category