data/TWiki/VarENCODE.txt
author Colas Nahaboo <colas@nahaboo.net>
Sat, 26 Jan 2008 15:50:53 +0100
changeset 0 414e01d06fd5
permissions -rw-r--r--
RELEASE 4.2.0 freetown
     1 %META:TOPICINFO{author="TWikiContributor" date="1167874036" format="1.1" version="3"}%
     2 %META:TOPICPARENT{name="TWikiVariables"}%
     3 #VarENCODE
     4 ---+++ ENCODE{"string"} -- encodes a string to HTML entities
     5    * Encode "special" characters to HTML numeric entities. Encoded characters are:
     6       * all non-printable ASCII characters below space, except newline (="\n"=) and linefeed (="\r"=)
     7       * HTML special characters ="<"=, =">"=, ="&"=, single quote (='=) and double quote (="=)
     8       * TWiki special characters ="%"=, ="["=, ="]"=, ="@"=, ="_"=, ="*"=, ="="= and ="|"=
     9    * Syntax: =%<nop>ENCODE{"string"}%=
    10    * Supported parameters:
    11      | *Parameter:* | *Description:* | *Default:* |
    12      | ="string"= | String to encode | required (can be empty) |
    13      | =type="entity"= | Encode special characters into HTML entities, like a double quote into =&amp;#034;=. Does *not* encode =\n= or =\r=. | =type="url"= |
    14      | =type="html"= | As =type="entity"= except it also encodes =\n= and =\r= | =type="url"= |
    15      | =type="quotes"= | Escape double quotes with backslashes (=\"=), does not change other characters | =type="url"= |
    16      | =type="url"= | Encode special characters for URL parameter use, like a double quote into =%22= | (this is the default) |
    17    * Example: =%<nop>ENCODE{"spaced name"}%= expands to =%ENCODE{"spaced name"}%=
    18    * __%X% Note:__ Values of HTML input fields must be entity encoded.%BR% Example: =&lt;input type="text" name="address" value="%<nop>ENCODE{ "any text" type="entity" }%" /&gt;=
    19    * __%X% Note:__ Double quotes in strings must be escaped when passed into other TWiki variables.%BR% Example: =%<nop>SEARCH{ "%<nop>ENCODE{ "string with "quotes"" type="quotes" }%" noheader="on" }%=
    20 
    21    * Related: [[%IF{"'%INCLUDINGTOPIC%'='TWikiVariables'" then="#"}%VarURLPARAM][URLPARAM]]
    22