HTMLEncode
Converts a string into a HTML-safe version by substituting 'unsafe' characters with their 'safe' equivalents, allowing a web browser to render them without interpreting them as markup.
Text converted using this function can be reverted to its original state using the HTMLDecode function.
Syntax
HTMLEncode( StringInput );
Parameters
| Parameter Name | Type | Description | Optional? | Default Value |
|---|---|---|---|---|
| StringInput | String | The string to convert. | No | n/a |
Output
A HTML-friendly version of the supplied string.
Use Case
A content manager needs to render mathematical formulae as part of a site's content. Some of the characters used in these formulae are also used in HTML markup, so the following expression is used to convert segments of site content into an HTML-friendly format:
ConvertedContent:= HTMLEncode( ContentForConversion );
In one example, the following string is passed to the function via the ContentForConversion keyword:
Solve the following inequality: 4x > 4 + 7
The result of the function call, which is assigned to the ConvertedContent keyword, is as follows:
Solve the following inequality: 4X > 4 + 7
This string allows a browser to render the formula correctly without any part of it being mistaken for markup.