Difference between revisions of "Ns quotehtml"

From AOLserver Wiki
Jump to navigation Jump to search
(imported from WiKit id 624)
 
 
Line 14: Line 14:
  
 
: Returns the contents of ''html'' with certain characters that are special in HTML replaced with an escape code.  This allows text displayed in a webpage that might otherwise be interpreted as containing HTML markup instructions to be interpreted as literal characters to be displayed.  Specifically:
 
: Returns the contents of ''html'' with certain characters that are special in HTML replaced with an escape code.  This allows text displayed in a webpage that might otherwise be interpreted as containing HTML markup instructions to be interpreted as literal characters to be displayed.  Specifically:
* < becomes &lt;
+
* < becomes &amp;lt;
* > becomes &gt;
+
* > becomes &amp;gt;
* & becomes &amp;
+
* & becomes &amp;amp;
* ' becomes &#39;
+
* ' becomes &amp;#39;
* " becomes &#34;
+
* " becomes &amp;#34;
  
 
: All other characters are unmodified in the output.
 
: All other characters are unmodified in the output.
Line 27: Line 27:
 
     Hello World!
 
     Hello World!
  
     % ns_quotehtml "The <STRONG> tag is used to indicate strongly emphasized text."
+
     % ns_quotehtml "The &lt;STRONG&gt; tag is used to indicate strongly emphasized text."
     The &lt;STRONG&gt; tag is used to indicate strongly emphasized text.
+
     The &amp;lt;STRONG&amp;gt; tag is used to indicate strongly emphasized text.
 +
 
 +
    % ns_quotehtml {&lt;span class="foo"&gt;}
 +
    &amp;lt;span class=&amp;#34;foo&amp;#34;&amp;gt;
  
    % ns_quotehtml {<td id='cell_1_2' class="red">&nbsp;</td>}
 
    &lt;td id=&#39;cell_1_2&#39; class=&#34;red&#34;&gt;&amp;nbsp;&lt;/td&gt;
 
  
 
'''NOTES'''
 
'''NOTES'''

Latest revision as of 11:08, 8 August 2006

Man page: http://aolserver.com/docs/tcl/ns_quotehtml.html


NAME

ns_quotehtml - Escape HTML characters so they appear as-is in HTML pages

SYNOPSIS

ns_quotehtml html

DESCRIPTION

Returns the contents of html with certain characters that are special in HTML replaced with an escape code. This allows text displayed in a webpage that might otherwise be interpreted as containing HTML markup instructions to be interpreted as literal characters to be displayed. Specifically:
  • < becomes &lt;
  • > becomes &gt;
  • & becomes &amp;
  • ' becomes &#39;
  • " becomes &#34;
All other characters are unmodified in the output.

EXAMPLES

   % ns_quotehtml "Hello World!"
   Hello World!
   % ns_quotehtml "The <STRONG> tag is used to indicate strongly emphasized text."
   The &lt;STRONG&gt; tag is used to indicate strongly emphasized text.
   % ns_quotehtml {<span class="foo">}
   &lt;span class=&#34;foo&#34;&gt;


NOTES

The set of characters that are substituted and their replacements may be different in previous versions of AOLserver. For example, AOLserver 2.x does not escape single or double-quotes.

Category Documentation - Category Core Tcl API