Dear friends,
I need a function to encode decode url
http%3A%2F%2F127.0.0.1 <<<< >>>>> http://127.0.0.1
Where Can I find it?
Many thanks
Marco
#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
Carlos Mora wrote:Hi Marc,
the native Harbour ones, without any doubt! The are updated with the rtl, written in C so the are _faster_. I posted the old ones just in case, for really old projects it may be useful.
Best regards
Portal_UYAP.obj : error LNK2001: unresolved external symbol _HB_FUN_HB_URLENCODE
hbhttpd.lib
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 36 guests