Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Hexadecimal to string and vice versa
Message
From
04/06/2006 12:01:39
 
 
To
All
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Title:
Hexadecimal to string and vice versa
Environment versions
Environment:
VB 8.0
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01126987
Message ID:
01126987
Views:
79
I just found that those two functions are not necessarily the opposite of each other. In a specific situations, when I pass a certain string to be hexadecimaled, when doing the reverse process, I end up with a different result. Here is the code:
        ' Convert from string to hexadecimal
        ' expC1 String
        Public Function StringToHexadecimal(ByVal tcString As String) As String
            Dim lcString As String = ""
            Dim lnCounter As Integer = 0
            For lnCounter = 1 To tcString.Length
                lcString = lcString + Hex(Asc(Mid(tcString, lnCounter, 1)))
            Next
            Return lcString
        End Function

        ' Convert from hexadecimal to string
        ' expC1 String in hexadecimal
        Public Function HexadecimalToString(ByVal tcString As String) As String
            Dim lcString As String = ""
            Dim lnCounter As Integer = 0
            For lnCounter = 1 To tcString.Length Step 2
                lcString = lcString + Chr("&H" + Mid(tcString, lnCounter, 2))
            Next
            Return lcString
        End Function
If my string is this:
SQL: Column 'NOCOUNTRY' is not found.

SELECT Country.NoCountry AS Name,Country.Numero AS PrimaryKey FROM Country ORDER BY 1
Doing the following:
lcHtml=oApp.HexadecimalToString(oApp.StringToHexadecimal(cHtml))
Would return this:
SQL: Column 'NOCOUNTRY' is not found.ÚÚSELECT Country.NoCountry AS Name,Country.Numero AS PrimaryKey FROM Country ORDER BY 1
Anyone knows what I would need to adjust in the functions to avoid such situations?
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Next
Reply
Map
View

Click here to load this message in the networking platform