Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

unescape method

Status
Not open for further replies.

ghobbes98

Programmer
Feb 7, 2002
62
IE
I was wondering if there is anything in vb that can do this for me. I have to unescape a string that is being put into a database from somebody using jscript.
I have tried looking up the help in vb documentation to no avail.
Any suggestions would be great
Thanks
Hobbes

"you can't outrun death but you can sure make the bast**d work for it"
 
this is a function i use, however it was written by some one else (i found it as a vb equivalent for URLDecode)

Function unescape(str As String) As String
Dim strtemp As String: strtemp = ""
Dim strChar As String: strChar = ""
Dim strHex As String:
Dim strDec As String:
Dim lngCurrent As Long: lngCurrent = 1
Dim nAsciiVal As Integer
Dim bDone As Boolean: bDone = False

While Not bDone
If Mid(str, lngCurrent, 1) = "+" Then
strtemp = strtemp & " "
lngCurrent = lngCurrent + 1
ElseIf Mid(str, lngCurrent, 1) = "%" Then
strHex = Mid(str, lngCurrent + 1, 2)
If strHex <> &quot;&quot; Then
strDec = Chr(Val(&quot;&H&quot; & strHex))
strtemp = strtemp & strDec
lngCurrent = lngCurrent + 3
End If
Else
strtemp = strtemp & Mid(str, lngCurrent, 1)
lngCurrent = lngCurrent + 1
End If
If lngCurrent > Len(str) Then
bDone = True
End If
Wend

unescape = strtemp
End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top