UTF-8 encoding of Unicode characters.
Imports System
Imports System.Text
Imports Microsoft.VisualBasic.Strings
Class UTF8EncodingExample
Public Shared Sub Main()
Dim utf8 As New UTF8Encoding()
Dim unicodeString As String = "Pi (" & ChrW(928) & ") and Sigma (" & ChrW(931) & ")."
Console.WriteLine(unicodeString)
Dim encodedBytes As Byte() = utf8.GetBytes(unicodeString)
Dim b As Byte
For Each b In encodedBytes
Console.Write("[{0}]", b)
Next b
Dim decodedString As String = utf8.GetString(encodedBytes)
Console.WriteLine(decodedString)
End Sub
End Class
Related examples in the same category