Coding Cookbook/URL Encode

Encode special characters in a string, so that it can be used in an URL

VBScript solution
function URLEncode (sInput) if IsNull(sInput) then URLEncode = "" exit function end if URLEncode = sInput URLEncode = Replace(URLEncode, chr(0), "") URLEncode = Replace(URLEncode, "%", "%25") URLEncode = Replace(URLEncode, " ", "%20") URLEncode = Replace(URLEncode, """", "%22") URLEncode = Replace(URLEncode, "&", "%26") URLEncode = Replace(URLEncode, "'", "%27") URLEncode = Replace(URLEncode, "/", "%2F") URLEncode = Replace(URLEncode, "?", "%3F") URLEncode = Replace(URLEncode, "\", "%5C") end function

function URLEncode (sInput) Escape(sInput) end function