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

From m204wiki
Jump to navigation Jump to search
(Automatically generated page update)
mNo edit summary
 
(3 intermediate revisions by the same user not shown)
Line 5: Line 5:


==Syntax==
==Syntax==
<p class="syntax"><span class="term">%OUT</span> = <span class="literal">$Web_URL_Encode</span>( <span class="term">input_string</span> )
<p class="syntax"><span class="term">%out</span> = <span class="literal">$Web_URL_Encode</span>( <span class="term">input_string</span> )
</p>
</p>


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


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.  
The only parameter is the input string to be encoded. If this string is omitted, a null string is returned.  


<var>$Web_URL_Encode</var> and <var>$Web_URL_Encode_Lstr</var> are useful for composing the isindex string portion of a URL ("HTTP://host/path?isindex") for redirection, or for composing the <tt>HREF=</tt> value in the HTML anchor tag ("<A HREF=...").
==Usage notes==
<ul>
<li><var>$Web_URL_Encode_Lstr</var> is identical to <var>$Web_URL_Encode</var> with the exception that it is longstring capable: it can take a longstring input and produce the appropriate longstring output.
 
<li>For <var>$Web_URL_Encode</var>, 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 <var>$Web_URL_Encode_Lstr</var>, no truncation should occur.
 
<li><var>$Web_URL_Encode</var> and <var>$Web_URL_Encode_Lstr</var> are useful for composing the isindex string portion of a URL ("HTTP://host/path?isindex") for redirection, or for composing the <code>HREF=</code> value in the HTML anchor tag ("<A HREF=...").
 
<li><p class="code">&#42; Use <var>$Web_URL_Encode</var> to create % hex hex like browser does with FORM METHOD=GET


<p class="code">&#42; Use <var>$Web_URL_Encode</var> to create % hex hex like browser does with FORM METHOD=GET
printText <form method=get action="{$Web_Hdr_Parm('URL')}">
printText <form method=get action="{$Web_Hdr_Parm('URL')}">
printText Use this isindex: <input name=a value="">  
printText Use this isindex: <input name=a value="">  
Line 20: Line 27:
%URLENC = $Web_URL_Encode(%INPUTA)
%URLENC = $Web_URL_Encode(%INPUTA)
printText <input type=submit value=Submit>
printText <input type=submit value=Submit>
printText <br><a href="{$Web_Hdr_Parm('URL')}?input={%URLENC}">Click for same result</a>
printText &lt;br>&lt;a href="{$Web_Hdr_Parm('URL')}?input={%URLENC}">Click here for same result</a>
printText <br><hr><br>
 
printText <xmp>
printText &lt;br>&lt;hr>&lt;br>
printText &lt;xmp>
 
printText PARM a:{%INPUTA}
printText PARM a:{%INPUTA}
printText URLENC:{%URLENC}
printText URLENC:{%URLENC}
printText </xmp>
printText &lt;/xmp>
</p>
</p>


If you enter the following into the form:
If you enter the following into the form:
<p class="code">10 + 3.14 * R*R*R * 2/3
<p class="code">10 + 3.14 * R*R*R * 2/3
</p>
</p>


The value displayed after URLENC is:
The value displayed after URLENC is:
<p class="code">10+%2B+3.14+*+R*R*R+*+2%2F3
<p class="code">10+%2B+3.14+*+R*R*R+*+2%2F3
</p>
</p>


<code>+</code> is used to stand for a blank, <code>%</code> introduces a hex encoding,<code>2B</code> is the ASCII code for <code>+</code>, and <code>2F</code> 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 ( . ).
<code>+</code> is used to stand for a blank, <code>%</code> introduces a hex encoding,<code>2B</code> is the ASCII code for <code>+</code>, and <code>2F</code> 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 ( . ).
</ul>


[[Category:Janus Web Server $functions|$Web_URL_Encode and $Web_URL_Encode_Lstr]]
[[Category:Janus Web Server $functions|$Web_URL_Encode and $Web_URL_Encode_Lstr]]

Latest revision as of 01:26, 16 April 2013

Do web URL encoding

$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

%out = $Web_URL_Encode( input_string )

$Web_URL_Encode takes a single string argument and returns that string with special characters encoded using the URL "% hex hex" format.

The only parameter is the input string to be encoded. If this string is omitted, a null string is returned.

Usage notes

  • $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.
  • 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 printText <form method=get action="{$Web_Hdr_Parm('URL')}"> printText Use this isindex: <input name=a value=""> %INPUTA = $Web_Parm('a') %URLENC = $Web_URL_Encode(%INPUTA) printText <input type=submit value=Submit> printText <br><a href="{$Web_Hdr_Parm('URL')}?input={%URLENC}">Click here for same result</a> printText <br><hr><br> printText <xmp> printText PARM a:{%INPUTA} printText URLENC:{%URLENC} printText </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 ( . ).