Encode into URL "% hex hex" format
Note: Many $functions have been deprecated in favor of Object Oriented methods. The OO equivalent for $Sock_URL_Encode is the URLEncode method.
$Sock_URL_Encode encodes special characters into the URL "% hex hex" format, which has particular use constructing URLs, especially those containing query strings for HTTP connections. $Sock_URL_Encode is also useful for encoding form post data for HTTP connections.
%longStr = $Sock_URL_Encode(string, sockNum)
|%longStr||A Longstring to contain the encoding of the input string.|
|string||The input string to be translated. If this string is omitted, a null string is returned.|
|sockNum||The socket number, which has associated with it the translation table used for encoding special characters.|
- The translation table associated with the socket number is necessary because special characters are converted to the hexadecimal representations of their ASCII values, even though the input and output strings are both in EBCDIC. So any data that must be encoded as hexadecimal must be translated to ASCII first, which means that the appropriate ASCII-to-EBCDIC translation table must be indicated to $Sock_URL_Encode via the socket number.
$Sock_URL_Encode is useful when composing the query string portion of a URL
HTTP://host/path?query), or when composing form data for a post request over HTTP:
* Use $Sock_URL_Encode to create % hex hex %r = $Sock_Send(%x, 'GET /') %r = $Sock_Send(%x, %URL) %r = $Sock_Send(%x, '?info=') %r = $Sock_Send(%x, $Sock_URL_Encode(%info)) %r = $Sock_SendLn(%x, ' HTTP/1.0')
For example, if
10 + 3.14 * R*R*R * 2/3
The following value would be sent to the web server after the
+ is used to stand for a blank,
% introduces a hex encoding,
2B is the ASCII code for a plus sign (+), and
2F is the ASCII code for a slash (/).
The non-alphanumeric characters that $Sock_URL_Encode does not encode are:
. ( ) ! $ * - _