NaviServer - programmable web server

[ Main Table Of Contents | Table Of Contents | Keyword Index ]

# ns_quotehtml(n) 4.99.8 naviserver "NaviServer Built-in Commands"

## Name

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

## Table Of Contents

## 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 &amp;

  < becomes &lt;

  > becomes &gt;

  ' becomes &#39;

  " becomes &#34;

All other characters are unmodified in the output.

## COMMANDS

ns_quotehtml html

## EXAMPLES

       % ns_quotehtml "Hello World!"
       Hello World!

       % ns_quotehtml "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;

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