Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Hexadecimal to string and vice versa
Message
De
04/06/2006 12:01:39
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Titre:
Hexadecimal to string and vice versa
Versions des environnements
Environment:
VB 8.0
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
01126987
Message ID:
01126987
Vues:
72
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform