Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Looking for freee and fast URLDecode function
Message
From
24/04/2002 12:32:59
 
 
To
23/04/2002 13:34:21
General information
Forum:
Visual FoxPro
Category:
Internet applications
Miscellaneous
Thread ID:
00646395
Message ID:
00648758
Views:
19
This is even faster, note the first comment.
Function URLDecode4

	***
	*** If tcInput contains "%00", the string will be terminated at that 
	*** character.
	***

	*** URLDecodes a text string:
	* Replaces %hh tokens with ascii characters

	*** Input: tcInput - Text string to decode
	*** Return: Decoded string
	* Author: Albert

	Lparameter tcInput

	tcInput = Chrtran(tcInput, "+", " ")

	*!*	UrlUnescape
	*!*	Converts escape sequences back into ordinary characters.

	*!*	HRESULT UrlUnescape(
	*!*	  LPTSTR pszURL,
	*!*	  LPTSTR pszUnescaped,
	*!*	  LPDWORD pcchUnescaped,
	*!*	  DWORD dwFlags
	*!*	);

	*!*	Parameters
	*!*	pszURL - [in/out] Pointer to a NULL-terminated string with
	*!*	    the URL. If dwFlags is set to URL_UNESCAPE_INPLACE, the 
	*!*	    converted string is returned through this parameter.
	*!*	pszUnescaped - [out] Pointer to a buffer that will receive a 
	*!*	    NULL-terminated string containing the unescaped version 
	*!*	    of pszURL. If URL_UNESCAPE_INPLACE is set in dwFlags,
	*!*	    this parameter is ignored.
	*!*	pcchUnescaped - [in/out] Number of characters in the buffer 
	*!*	    pointed to by pcchUnescaped. On entry, the value 
	*!*	    pcchUnescaped points to is set to the size of the 
	*!*	    buffer. If the function returns a success code, the 
	*!*	    value that pcchUnescaped points to is set to the number 
	*!*	    of characters written to that buffer, not counting the 
	*!*	    terminating NULL character. If an E_POINTER error code 
	*!*	    is returned, the buffer was too small, and the value 
	*!*	    pcchUnescaped points to is set to the required number of 
	*!*	    characters that the buffer must be able to contain. If 
	*!*	    any other errors are returned, the value that 
	*!*	    pcchUnescaped points to is undefined.
	*!*	dwFlags - [in] Flags that control which characters are 
	*!*	    unescaped. It can be a combination of the following 
	*!*	    flags. Flag Description
	*!*		URL_DONT_UNESCAPE_EXTRA_INFO Don't convert the #
	*!*	            or ? character, or any characters following them 
	*!*	            in the string.
	*!*		URL_UNESCAPE_INPLACE Use pszURL to return the 
	*!*	            converted string instead of pszUnescaped.

	*!*	Return Values
	*!*	Returns an OLE success code if successful. If the 
	*!*	URL_UNESCAPE_INPLACE flag is not set, the value pointed to 
	*!*	by pcchUnescaped will be set to the number of characters in 
	*!*	the output buffer pointed to by pszUnescaped. Returns 
	*!*	E_POINTER if the URL_UNESCAPE_INPLACE flag is not set and 
	*!*	the output buffer is too small. The pcchUnescaped parameter 
	*!*	will be set to the required buffer size. Otherwise, returns 
	*!*	an OLE error value.

	*!*	Remarks
	*!*	An escape sequence has the form "%xy".

	*!*	Requirements
	*!*	  Version 5.00 and later of Shlwapi.dll

	*!*	  Windows NT/2000: Requires Windows 2000 (or Windows NT 4.0 
	*!*	      with Internet Explorer 5.0 or later).
	*!*	  Windows 95/98: Requires Windows 98 (or Windows 95 with 
	*!*	      Internet Explorer 5.0 or later).
	*!*	  Header: Declared in shlwapi.h.
	*!*	  Import Library: shlwapi.lib.

	Declare Integer UrlUnescape In shlwapi.Dll As UrlUnescape ;
		string pszURL, ;
		string @ pszUnescaped, ;
		integer @ pcchUnescaped, ;
		integer dwFlags

	Local lcOutput, lnLength
	lnLength = Len(tcInput)
	lcOutput = Replicate(Chr(0), lnLength)

	If 0 = UrlUnescape(tcInput, @lcOutput, @lnLength, 0)
		lcOutput = Left(lcOutput, lnLength)
		Return lcOutput
	Else
		Return ""
	Endif
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform