web-based UTF encoder.

I would like to know how to convert chinese characters into hex string in vb.net?

thanks a lot!!!
Who is Participating?
ee_ai_constructConnect With a Mentor Commented:
Question award reversed.   Point passing.
500 Points Forfeit

ai, cs admin
try this

Imports System.Text
Public Class chiutfencoding
    Inherits System.Web.UI.Page
    Dim UniEnc As UnicodeEncoding = New UnicodeEncoding(True, True)
    Dim UTF8Enc As UTF8Encoding = New UTF8Encoding
    Dim UTF7Enc As UTF7Encoding = New UTF7Encoding

#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub
    Protected WithEvents lblInput As System.Web.UI.WebControls.Label
    Protected WithEvents txtInput As System.Web.UI.WebControls.TextBox
    Protected WithEvents butShowByte As System.Web.UI.WebControls.Button
    Protected WithEvents lblUTF16 As System.Web.UI.WebControls.Label
    Protected WithEvents lblUTF8 As System.Web.UI.WebControls.Label
    Protected WithEvents lblUTF7 As System.Web.UI.WebControls.Label
    Protected WithEvents txtUTF16 As System.Web.UI.WebControls.TextBox
    Protected WithEvents txtUTF8 As System.Web.UI.WebControls.TextBox
    Protected WithEvents txtUTF7 As System.Web.UI.WebControls.TextBox

    'NOTE: The following placeholder declaration is required by the Web Form Designer.
    'Do not delete or move it.
    Private designerPlaceholderDeclaration As System.Object

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
    End Sub

#End Region

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here
    End Sub

    Private Sub butShowByte_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butShowByte.Click
        txtUTF16.Text = ShowByte(txtInput.Text, "UTF-16")
        txtUTF8.Text = ShowByte(txtInput.Text, "UTF-8")
        txtUTF7.Text = ShowByte(txtInput.Text, "UTF-7")
    End Sub

    Function ShowByte(ByVal inStr As String, ByVal encode As String) As String
        Dim result As String
        Dim bArray() As Byte
        result = ""
        Select Case encode
            Case "UTF-16"
                bArray = UniEnc.GetBytes(inStr)
            Case "UTF-8"
                bArray = UTF8Enc.GetBytes(inStr)
            Case "UTF-7"
                bArray = UTF7Enc.GetBytes(inStr)
        End Select
        Dim len As Integer = bArray.Length
        For i As Integer = 0 To len - 1
            result = result & " " & Hex(bArray(i))
        Return result
    End Function
End Class
ho_alanAuthor Commented:
let me try the codes now
All Courses

From novice to tech pro — start learning today.