?
Solved

web-based UTF encoder.

Posted on 2005-03-07
4
Medium Priority
?
955 Views
Last Modified: 2008-01-09
I would like to know how to convert chinese characters into hex string in vb.net?

thanks a lot!!!
0
Comment
Question by:ho_alan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 3

Expert Comment

by:smallee
ID: 13476140
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.
        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
0
 
LVL 5

Author Comment

by:ho_alan
ID: 13476157
let me try the codes now
thanks!
0
 

Accepted Solution

by:
ee_ai_construct earned 0 total points
ID: 13477830
Question award reversed.   Point passing.
500 Points Forfeit

ai, cs admin
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Suggested Courses
Course of the Month15 days, 14 hours left to enroll

741 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question