Imports System
Imports System.Text
Imports Microsoft.VisualBasic.Strings
Class ASCIIEncodingExample
Public Shared Sub Main()
Dim bytes() As Byte
' ChrW(928) = Pi
' ChrW(931) = Sigma
Dim chars() As Char = {ChrW(928), ChrW(931)}
Dim ascii As New ASCIIEncoding()
Dim byteCount As Integer = ascii.GetByteCount(chars, 1, 2)
bytes = New Byte(byteCount - 1){}
Dim bytesEncodedCount As Integer = ascii.GetBytes(chars, 1, 2, bytes, 0)
Console.WriteLine("{0} bytes used to encode characters.", bytesEncodedCount)
Dim b As Byte
For Each b In bytes
Console.Write("[{0}]", b)
Next b
End Sub
End Class