function urlencoding(vstrin)
	dim i,strreturn
    strreturn = ""
    for i = 1 to len(vstrin)
        thischr = mid(vstrin,i,1)
        if abs(asc(thischr)) < &hff then
            strreturn = strreturn & thischr
        else
            innercode = asc(thischr)
            if innercode < 0 then
                innercode = innercode + &h10000
            end if
            hight8 = (innercode  and &hff00)\ &hff
            low8 = innercode and &hff
            strreturn = strreturn & "%" & hex(hight8) &  "%" & hex(low8)
        end if
    next
    urlencoding = strreturn
end function

function urldecoding(vstrin)
        Dim i,strreturn,strSpecial,thischr,intasc
        strSpecial = "!""#$%&'()*+,-./:;<=>?@[\]^_`{|}~"
        strreturn = ""
        For i = 1 to len(vstrin)        
                thischr = mid(vstrin,i,1)
                If thischr="%" Then
                        intasc=eval("&h"+mid(vstrin,i+1,2))
                        If instr(strSpecial,chr(intasc))>0 Then
                                strreturn= strreturn & chr(intasc)
                                i=i+2
                        Else
                                intasc=eval("&h"+mid(vstrin,i+1,2)+mid(vstrin,i+4,2))
                                strreturn= strreturn & chr(intasc)
                                i=i+5
                        End If
                Else
                        If thischr="+" Then
                                strreturn= strreturn & " "
                        Else
                                strreturn= strreturn & thischr
                        End If
                End If
        Next
        urlDecoding = strreturn
End function