UTF-8 encoding of Unicode characters. : UTF8Encoding « Internationalization I18N « VB.Net






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

1.Calculates number of characters produced by decoding a sequence of bytes from the specified byte array.
2.Decodes a sequence of bytes from the specified byte array into the specified character array.
3.Obtains a decoder that converts a UTF-8 encoded sequence of bytes into a sequence of Unicode characters.
4.Encoding.UTF8
5.Create UTF8Encoding class
6.Create UTF8Encoding class.
7.UTF8Encoding.Equals