#define URL_CODE { '%21', '%2A', '%27', '%28', '%29', '%3B', '%3A', '%40', '%26', '%3D', '%2B', '%24', '%2C', '%2F', '%3F', '%25', '%23', '%5B', '%5D' }
#define URL_CHAR { '!' , '*' , "'" , "(" , ")" , ";" , ":" , "@" , "&" , "=" , "+" , "$" , "," , "/" , "?" , "%" , "#" , "[" , "]" }
FUNCTION urlencode( cString )
LOCAL cResult, i, nAt, Ch
cResult:= ''
FOR i:= 1 To LEN( cString )
IF ( nAT := aScan( URL_CHAR, Ch:= SubStr( cString, i, 1 ) ) ) > 0
cResult+= URL_CODE[ nAt ]
ELSE
cResult+= Ch
ENDIF
NEXT
RETURN cResult
FUNCTION urldecode( cString )
LOCAL cResult, i, nAt, cH
cResult:= ''
FOR i:= 1 To LEN( cString )
IF ( nAT := aScan( URL_CODE, Ch:= SubStr( cString, i, 3 ) ) ) > 0
cResult+= URL_CHAR[ nAt ]
i+= 2
ELSE
cResult+= Left( Ch, 1 )
ENDIF
NEXT
RETURN cResult