UnicodeEncoding Class represents a UTF-16 encoding of Unicode characters. : UnicodeEncoding « Internationalization I18N « VB.Net






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

1.Create a UnicodeEncoding to support little-endian byte ordering and include the Unicode byte order mark.
2.Create a UnicodeEncoding to support little-endian byte ordering and not include the Unicode byte order mark
3.Create a UnicodeEncoding to support big-endian byte ordering and include the Unicode byte order mark
4.Create a UnicodeEncoding to support big-endian byte ordering and not include the Unicode byte order mark
5.Create UnicodeEncoding class.
6.UnicodeEncoding.CharSize