UnicodeEncoding Class represents a UTF-16 encoding of Unicode characters.
Imports System
Imports System.Text
Imports Microsoft.VisualBasic.Strings
Class UnicodeEncodingExample
Public Shared Sub Main()
Dim uni As New UnicodeEncoding()
Dim unicodeString As String = "Sigma " & ChrW(931)
Console.WriteLine("Original string:")
Console.WriteLine(unicodeString)
' Encode the string.
Dim encodedBytes As Byte() = uni.GetBytes(unicodeString)
Dim b As Byte
For Each b In encodedBytes
Console.Write("[{0}]", b)
Next b
' Decode bytes back to string.
Dim decodedString As String = uni.GetString(encodedBytes)
Console.WriteLine(decodedString)
End Sub
End Class
Related examples in the same category