Sample code for 30+ languages & platforms
Classic ASP

URL Encoding and Decoding

See more Encryption Examples

Demonstrates URL encoding and decoding.

Chilkat Classic ASP Downloads

Classic ASP
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
success = 0

'  To URL encoding a string:
s = "Why a > b?"

set sb = Server.CreateObject("Chilkat.StringBuilder")
success = sb.Append(s)

'  URL encode the string.
success = sb.Encode("url","utf-8")

'  Show the URL encoded string:
sEncoded = sb.GetAsString()
Response.Write "<pre>" & Server.HTMLEncode( sEncoded) & "</pre>"

'  The result is:  Why%20a%20%3E%20b%3F

'  If you prefer "+" instead of "%20" for SPACE chars:
numReplaced = sb.Replace("%20","+")
Response.Write "<pre>" & Server.HTMLEncode( sb.GetAsString()) & "</pre>"

'  Output is:   Why+a+%3E+b%3F

'  To decode:
success = sb.Decode("url","utf-8")
Response.Write "<pre>" & Server.HTMLEncode( sb.GetAsString()) & "</pre>"

'  Result is: Why a > b?

%>
</body>
</html>