EscapeHTML

Mon 01 January 2018

Syntax

EscapeHTML(TextString)

Description

Use the EscapeHTML function to replace all characters in TextString that would otherwise be interpreted as markup sequences.

The characters that are replaced are ones that would cause the browser to interpret them as HTML tags or other markup if they aren't encoded, and therefore pre-formatted HTML should not be passed to this function unless the output desired is a rendering of the HTML code itself as opposed to it's interpretation. This function is intended to make the text "browser safe".

This function is for use with strings that display in an HTML area.

Either HTML character entities (eg. &lt) or Numeric Character Representations (e.g. &#039) are output by the EscapeHTML function, depending on the character passed. The table below shows the escaping that is performed by EscapeHTML.

In addition to escaping characters that could be misinterpreted as HTML tags or other elements, EscapeHTML escapes the percentage sign (%) as this could interfere with meta HTML processing. As all PeopleTools HTML is generated in Unicode, it is not necessary to escape other Unicode characters — their value may be passed directly to the browser instead of a character entity or in Numeric Character Representation.

The following table lists the Unicode characters that are escaped by the EscapeHTML function.

For example, the less-than symbol (<) is replaced with &lt. , a single quotation mark (') is replaced with &#039. , and so on.

Unicode Character Name

Glyph

Escape Sequence

Quotation mark

”

&quot;

Ampersand

&

&amp;

Less than sign

<

&lt;

Apostrophe, single quote

'

&#039;

Percentage sign

%

&#037;

New line

Not applicable

<BR>

Parameters

Field or Control

Definition

TextString

Specify a string of HTML that contains characters that must be replaced with HTML escape sequences.

Returns

A string containing the original text plus HTML escape sequences.