RPGspURLEncode Function


Encodes a string so that it is safe to pass as a query string parameter. Special characters like slashes ('/') or equal signs ('=') are converted to hexadecimal.


Syntax

RPGspURLEncode(character string)

Part Description
character string Required. Any character string that is to be passed to a URL as a query string parameter.


Remarks

There are several characters that have a special meaning and cannot be passed directly to the URL as data. For example, an ampersand ('&') is a separator character for multiple query string parameters. If your parameter values contain ampersands, the browser will not know whether this character is a separator or actually part of the data. To resolve this, we encode the data being passed. The browser will recognize a percent sign ('%') followed by a hexadecimal character representation as an encoded character, and automatically decode it.

For example, RPGspURLEncode(''A+B=C'') will return 'A%2BB%3DC'. When 'A%2BB%3DC' is passed to a URL, the browser will recognize this as 'A+B=C'.

To be safe, you should always encode character data passed to a URL with the RPGspURLEncode function.


Example

Here is a snippet of HTML that uses RPGspURLEncode within a link:

<A href="sndemail.pgm?EMAIL=<% RPGspURLEncode(EML) %>"> Click to send e-mail </A>


See Also

RPGspHTMLEncode

RPGspIn

%Char


Profound Logic Software, Inc.
www.ProfoundLogic.com
(937) 439-7925