LISTSERV Maestro 11.0-20 Help Table Of Contents

Calculation Formulas

Back to Calculation Formulas Overview
Back to Functions Overview


Function "HTMLEncode"

HTMLEncode(arg [, encodeWhitespace])

Function: Returns the given argument with the characters that are unsafe to use in a HTML context encoded into HTML entities, so that the resulting text can be safely included in a HTML context:
< becomes &lt;
> becomes &gt;
& becomes &amp;
" becomes &#34;
' becomes &#39;

Return-Type: Text or Text Set

Arguments:
arg - Single Argument or Set of any type: If a single argument is given, then this argument is converted into a text (if necessary), the text is encoded and the result is returned. If a set is given, then all elements in the set are converted into texts (if necessary) which are then encoded and a text set with these encoded texts is returned. Arguments of type Number and Number Set are converted according to the automatic type conversion rules. An argument of type Boolean is converted into the text "true" or "false".

(The second argument is optional)

encodeWhitespace - Type Boolean: If "true", then the following additional whitespace encoding will be performed: All linebreaks (CR, LF or CRLF) are replaced with "<br>CRLF". This makes the linebreaks visible in a HTML context. Also, all consecutive sequences of more than one space are modified, so that the sequence consists of alternating occurences of a normal space and a non-breaking space &nbsp;. E.g. a text with two words with a sequence of five spaces between them becomes this: "word1 &nbsp; &nbsp; word2". This makes the consecutive spaces visible in a HTML context, where they would normally be collated into a single visible space.
Defaults to "false" if left out.

Examples:
HTMLEncode("This text contains <characters>, which are not safe in HTML & need to be encoded")

© 2002-2023 L-Soft Sweden AB. All rights reserved.