Mega Code Archive
Use the GetByteCount to get the number of bytes required to encode an array of Unicode characters, using UTF8Encoding
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