Export (0) Print
Expand All

UrlUnescape function

Converts escape sequences back into ordinary characters.

Syntax


HRESULT UrlUnescape(
  _Inout_      PTSTR pszURL,
  _Out_opt_    PTSTR pszUnescaped,
  _Inout_opt_  DWORD *pcchUnescaped,
  DWORD dwFlags
);

Parameters

pszURL [in, out]

Type: PTSTR

A 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, optional]

Type: PTSTR

A pointer to a buffer that will receive a null-terminated string that contains the unescaped version of pszURL. If URL_UNESCAPE_INPLACE is set in dwFlags, this parameter is ignored.

pcchUnescaped [in, out, optional]

Type: DWORD*

The number of characters in the buffer pointed to by pszUnescaped. 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 to which pcchUnescaped points is set to the required number of characters that the buffer must be able to contain. If any other errors are returned, the value to which pcchUnescaped points is undefined.

dwFlags

Type: DWORD

Flags that control which characters are unescaped. It can be a combination of the following flags.

URL_DONT_UNESCAPE_EXTRA_INFO

Do not convert the # or ? character, or any characters following them in the string.

URL_UNESCAPE_AS_UTF8

Introduced in Windows 8. Decode URLs that were encoded by using the URL_ESCAPE_AS_UTF8 flag.

URL_UNESCAPE_INPLACE

Use pszURL to return the converted string instead of pszUnescaped.

Return value

Type: HRESULT

Returns S_OK 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 a standard error value.

Remarks

An escape sequence has the form "%xy".

Input strings cannot be longer than INTERNET_MAX_URL_LENGTH.

Requirements

Minimum supported client

Windows 2000 Professional, Windows XP [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Header

Shlwapi.h

Library

Shlwapi.lib

DLL

Shlwapi.dll (version 5.0 or later)

Unicode and ANSI names

UrlUnescapeW (Unicode) and UrlUnescapeA (ANSI)

 

 

Community Additions

ADD
Show:
© 2014 Microsoft