Use the GetByteCount to get the number of bytes required to encode an array of Unicode characters, using UTF8Encoding. : UniCode « Development « VB.Net Tutorial






Imports System
Imports System.Text
Imports Microsoft.VisualBasic.Strings

Class UTF8EncodingExample

    Public Shared Sub Main()
        Dim chars() As Char = {ChrW(35), ChrW(37), ChrW(8), ChrW(930)}

        Dim utf8 As New UTF8Encoding()
        Dim byteCount As Integer = utf8.GetByteCount(chars, 1, 2)
        Console.WriteLine("{0} bytes needed to encode characters.", byteCount)
    End Sub
End Class








7.29.UniCode
7.29.1.UI with UniCodeUI with UniCode
7.29.2.Decode a range of elements from a byte array and store them in a Unicode character array.
7.29.3.Use the GetByteCount to get the number of bytes required to encode an array of Unicode characters, using UTF8Encoding.
7.29.4.Encode Unicode characters array and store the encoded bytes in a byte array.