PowerShell
PowerShell
URL Encoding and Decoding
See more Encryption Examples
Demonstrates URL encoding and decoding.Chilkat PowerShell Downloads
Add-Type -Path "C:\chilkat\ChilkatDotNet47-x64\ChilkatDotNet47.dll"
$success = $false
# To URL encoding a string:
$s = "Why a > b?"
$sb = New-Object Chilkat.StringBuilder
$success = $sb.Append($s)
# URL encode the string.
$sb.Encode("url","utf-8")
# Show the URL encoded string:
$sEncoded = $sb.GetAsString()
$($sEncoded)
# The result is: Why%20a%20%3E%20b%3F
# If you prefer "+" instead of "%20" for SPACE chars:
$numReplaced = $sb.Replace("%20","+")
$($sb.GetAsString())
# Output is: Why+a+%3E+b%3F
# To decode:
$sb.Decode("url","utf-8")
$($sb.GetAsString())
# Result is: Why a > b?