Converting a string to a valid URL parameter format¶
web_encode() |
Convert a string to a valid URL parameter format |
SYNTAX
web_encode(string)
Convert the supplied string into a string that is always valid as a parameter in a URL.
This function should always be used when creating a parameter for a URL, because some characters in a URL have a special meaning. The function replaces any such characters with their equivalent escape sequence. For example:
Uncoded string |
Converted string |
“hello=bye” |
“hello%3Dbye” |
The “=” character has a special meaning and has therefore been replaced.
The function returns the converted string.
Note
The web_decode() function decodes a string encoded by this function.
New in version 6.3.0: See the new features.
The character conversion honors the value set in sys.CharSetEncodeFrom and sys.CharSetEncodeTo, so that the string received is supposed to be sys.CharSetEncodeFrom encoded while the result is converted into the sys.CharSetEncodeTo encoding.
EXAMPLES
print "<A HREF='" + encode_session_url(SREP_NAME + "?stock&STOCK=" \
/ web_encode(STOCK)) / "'>Return to product</A>"
print "<A HREF='" + encode_session_url(SREP_NAME + "?content.sch&SCPROG=scust&CUST=" \
/ web_encode(o_cust)) / "'>"; c_name; "</A> "
RELATED TOPICS |