I\'ve made a class to encode a string
Public Class UTF8
Public Shared Function encode(ByVal str As String)
Dim utf8Encoding As New System.Text.UT
Use UTF8.GetString(Byte[]) method.
We can check if a string is UTF-8 by examining the string BOM value. This is the correct code sample:
Public Shared Function encode(ByVal str As String) As String
'supply True as the construction parameter to indicate
'that you wanted the class to emit BOM (Byte Order Mark)
'NOTE: this BOM value is the indicator of a UTF-8 string
Dim utf8Encoding As New System.Text.UTF8Encoding(True)
Dim encodedString() As Byte
encodedString = utf8Encoding.GetBytes(str)
Return utf8Encoding.GetString(encodedString)
End Function