Name

urlencode — convert non-alphanumerics to URL encoded escape sequences

Synopsis

string urlencode(url);
string url;

Description

Returns the string url but with the following conversions:

  • Letters and digits are left unchanged.
  • Spaces are converted to "+" characters.
  • All other characters are converted to URL escape codes of the form "%xx", where xx is the ASCII character code in hexidecimal form.

This function is most commonly used for forming URLs with arbitrary data, as shown in the example below.

Example 56. urlencode Example

// Create a hyperlink with encoded data
print("<a href=\" + translate("otherpage.rsp") + "?data="
  + htmlencode(urlencode(somedata)) + "\">Click Me!</a>");