Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Looking for freee and fast URLDecode function
Message
 
 
General information
Forum:
Visual FoxPro
Category:
Internet applications
Miscellaneous
Thread ID:
00646395
Message ID:
00650198
Views:
30
Ed,
Am I correct in thinking that WinInet.DLL has greater ubiquity than SHLWAPI.DLL?

If this is true, then there are a bunch of URL manipulating functions. Specifically:

BOOL InternetCanonicalizeUrl(
LPCTSTR lpszUrl,
LPTSTR lpszBuffer,
LPDWORD lpdwBufferLength,
DWORD dwFlags
);

which if used with dwFlags = BitOR( ICU_DECODE , ICU_NO_ENCODE ) should give Andrus what he is looking for.

The following code sample is off the top of my head, so no one should expect it to run as-is!:
Declare Integer InternetCanonicalizeUrl In WinInet.DLL ;
   String @ cUrlToDecode ;
 , String @ cResultsBuffer ;
 , Integer @ iBufferLength ;
 , Integer iFlags

Declare Integer GetLastError In Win32Api

*- flags for InternetCanonicalizeUrl() and InternetCombineUrl() from WinInet.H

#define ICU_NO_ENCODE   0x20000000  && Don't convert unsafe characters to escape sequence.
#define ICU_DECODE      0x10000000  && Convert %XX escape sequences to characters.
#define ICU_NO_META     0x08000000  && Don't convert .. etc. meta path sequences.
#define ICU_ENCODE_SPACES_ONLY 0x04000000  && Encode spaces only.
#define ICU_BROWSER_MODE 0x02000000 && Special encode/decode rules for browser.

cUrlToDecode = "This%20is%20a%20test"

iBufferLength = Len( cUrlToDecode )
cResultsBuffer = Space( iBufferLength ) + Chr(0)
cUrlToDecode = cUrlToDecode + Chr(0)
iBufferLength = iBufferLength + 1

iResult = InternetCanonicalizeUrl( ;
            @cUrlToDecode ;
          , @cResultsBuffer ;
          , @iBufferLength ;
          , BitOR( ICU_DECODE , ICU_NO_ENCODE ))

TRUE = -1  && 0 for FALSE.
If iResult == TRUE
   Return Left( cResultsBuffer, iBufferLength )
Endif
Return "ERROR: " + Transform( GetLastError())
censored.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform