Encode characters
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
Dim firstchar As Byte() = encoding.GetBytes(chars, 0, 1)
Console.WriteLine("First character:")
ShowArray(firstchar)
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