ho_alan
asked on
web-based UTF encoder.
I would like to know how to convert chinese characters into hex string in vb.net?
thanks a lot!!!
thanks a lot!!!
ASKER
let me try the codes now
thanks!
thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.Debugg
End Sub
Protected WithEvents lblInput As System.Web.UI.WebControls.
Protected WithEvents txtInput As System.Web.UI.WebControls.
Protected WithEvents butShowByte As System.Web.UI.WebControls.
Protected WithEvents lblUTF16 As System.Web.UI.WebControls.
Protected WithEvents lblUTF8 As System.Web.UI.WebControls.
Protected WithEvents lblUTF7 As System.Web.UI.WebControls.
Protected WithEvents txtUTF16 As System.Web.UI.WebControls.
Protected WithEvents txtUTF8 As System.Web.UI.WebControls.
Protected WithEvents txtUTF7 As System.Web.UI.WebControls.
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclara
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.
InitializeComponent()
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))
Next
Return result
End Function
End Class