$Web URL Encode and $Web URL Encode Lstr: Difference between revisions

From m204wiki
Jump to navigation Jump to search
(Created page with "{{DISPLAYTITLE:$Web_URL_Encode and $Web_URL_Encode_Lstr}} <span class="pageSubtitle"><section begin="desc" />and $Web_URL_Encode_Lstr: Do web URL encoding<section end="desc" /></...")
 
m (1 revision)
(No difference)

Revision as of 21:38, 21 February 2011

<section begin="desc" />and $Web_URL_Encode_Lstr: Do web URL encoding<section end="desc" />


$Web_URL_Encode and $Web_URL_Encode_Lstr encode special characters into the URL "% hex hex" format, which has particular use constructing isindex strings for anchor tags or redirection.

Syntax

<section begin="syntax" /> %OUT = $Web_URL_Encode( input_string ) <section end="syntax" />


$Web_URL_Encode takes a single string argument and returns that string with special characters encoded using the URL "% hex hex" format. $Web_URL_Encode_Lstr is identical to $Web_URL_Encode with the exception that it is longstring capable: it can take a longstring input and produce the appropriate longstring output. $Web_URL_Encode_Lstr was introduced in Sirius Mods Version 6.8.

The only parameter is the input string to be encoded. If this string is omitted, a null string is returned. For $Web_URL_Encode, if the result of the encoding produces a string longer than 255, the result is truncated, at 255 (or less, if necessary, to avoid producing a partial "% hex hex" sequence). For $Web_URL_Encode_Lstr, no truncation should occur.

$Web_URL_Encode and $Web_URL_Encode_Lstr are useful for composing the isindex string portion of a URL ("HTTP://host/path?isindex") for redirection, or for composing the HREF= value in the HTML anchor tag ("<A HREF=...").

* Use $Web_URL_Encode to create % hex hex * like browser does with FORM METHOD=GET PRINT '<form method=get action="' WITH - $Web_Hdr_Parm('URL') WITH '">' PRINT 'Use this isindex: <input name=a value="">' %INPUTA = $Web_Parm('a') %URLENC = $Web_URL_Encode(%INPUTA) PRINT '<input type=submit value=Submit>' PRINT '
<a href="' WITH $Web_Hdr_Parm('URL') - WITH '?' WITH 'input=' WITH %URLENC WITH - '">Click here to get same result</a>' PRINT '



'

PRINT '<xmp>'

PRINT ' PARM a:' AND %INPUTA
PRINT ' URLENC:' AND %URLENC

PRINT '</xmp>'

If you enter the following into the form:

10 + 3.14 * R*R*R * 2/3

The value displayed after URLENC is:

10+%2B+3.14+*+R*R*R+*+2%2F3

+ is used to stand for a blank, % introduces a hex encoding,2B is the ASCII code for +, and 2F is the ASCII code for a forward slash ( / ). (Note: this is a subtle and tricky example.) Using Netscape 4.5 as the guide, the 4 non-alphanumerics that are not encoded are underscore ( _ ), hyphen ( - ), asterisk ( * ), and period ( . ).