Quick Start Decoding

suggest change

Note: these examples use the variables created in Quick Start Encoding. [uri]::UnescapeDataString does not treat + as a space. UrlDecode does. On PowerShell 6 and later, System.Web.HttpUtility is not loaded by default.

# url1: http%3A%2F%2Ftest.com%3Ftest%3Dmy%20value
[uri]::UnescapeDataString($url1)
# Returns: http://test.com?test=my value

# url2: http://test.com?test=my%20value
[uri]::UnescapeDataString($url2)
# Returns: http://test.com?test=my value

# url3: http%3a%2f%2ftest.com%3ftest%3dmy+value
[uri]::UnescapeDataString($url3)
# Returns: http://test.com?test=my+value

# There is no [uri]::UnescapeUriString(). UnescapeDataString covers that case.
# On PowerShell 6 and later, System.Web.HttpUtility is not loaded by default.
# url1: http%3A%2F%2Ftest.com%3Ftest%3Dmy%20value
[System.Web.HttpUtility]::UrlDecode($url1)
# Returns: http://test.com?test=my value

# url2: http://test.com?test=my%20value
[System.Web.HttpUtility]::UrlDecode($url2)
# Returns: http://test.com?test=my value

# url3: http%3a%2f%2ftest.com%3ftest%3dmy+value
[System.Web.HttpUtility]::UrlDecode($url3)
# Returns: http://test.com?test=my value

Note: HttpUtility.UrlDecode.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents