Imports System
Imports System.Text
Imports System.Data
Imports System.Web.UI.WebControls
Imports System.Configuration
Imports System.Math

Public Function MagicThaiChar(ByVal str As String) As String
        ‘Dim str As String = TextBox1.Text —
        Dim codePage As String = “windows-874”
        Dim targetEncoding As Encoding
        Dim encodedChars() As Byte\
        ‘ Gets the encoding for the specified code page.
        targetEncoding = Encoding.GetEncoding(codePage)
        ‘ Gets the byte representation of the specified string.
        encodedChars = targetEncoding.GetBytes(str)
        Dim s1 As String = System.Text.Encoding.UTF8.GetString(encodedChars)
        Return s1
    End Function