APGen Documentation Previous Topic: Util.HTMLEncode() Next Topic: Util.XMLEncode() Parent Topic: Util Object    Util Object
Util.URLEncode()
See Also:

The Util.URLEncode() method applies URL encoding rules to a string.

Syntax

VBScript:

strEncoded = Util.URLEncode( str )

JScript:

strEncoded = Util.URLEncode( str );

Object

Util The Util object.

Parameters

str The string to be encoded.

Return Value

strEncoded The URL encoded string.

Notes

Strings are URL encoded to make them valid URL strings for use in a browser.  For example, space characters and punctuation are not allowed in a filename in a browser, though they may be allowed in the web server's file system.

The rules for URL encoding are as follows: The ASCII characters 'a' through 'z', 'A' through 'Z', and '0' through '9' remain the same.  Since periods ('.') and slashes ('/' and '\') are valid in URLs as extension delimiters and directory separators, they are also left alone.  The space character ' ' is converted into a plus sign '+'.  All other characters are converted into the 3-character string of the form "%xy", where xy is the two-digit hexadecimal representation of the lower 8-bits of the character. 

Example

This example URLEncodes a filename to ensure the href is valid.

<%#

Dim sURL
...

#%>
<A href="
<%# =Util.URLEncode(sUrl) #%>">Hyperlink Text</A>
...

Applies To

Util Object