|
Util Object |
|
See Also: |
The Util.URLEncode() method applies URL encoding rules to a string.
VBScript:
JScript:
| Util | The Util object. |
| str | The string to be encoded. |
| strEncoded | The URL encoded string. |
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.
This example URLEncodes a filename to ensure the href is valid.
<%#
Dim sURL
...
#%>
<A href="<%# =Util.URLEncode(sUrl) #%>">Hyperlink Text</A>
...