HTML Encode
Table of Contents
Description
The htmlEncode function is used to transform all special HTML characters in the input text into HTML entities. This operation has several purposes, for example, to put HTML inside of HTML, to ensure the text will be properly rendered in the browser, etc. To perform reverse operation, i.e., decode HTML entities to HTML text, use htmlDecode function.
Note:
- The size of the supplied input text and the returned output text can individually be up to 300KB.
- This function supports until the HTML 4 version.
Syntax
<response> = <data>.htmlEncode();
<response> = htmlEncode(<data>);
where:
Params | Data type | Description |
<response> | TEXT | Specifies the response that represents the encoded HTML data |
<data> | TEXT | Specifies the HTML text that will be encoded. |
Example 1: Encode a HTML text to HTML entities
The following script encodes the input HTML text such that all the special characters will be transformed into their equivalent HTML entities.
response = htmlEncode("Your order is ready. You can track your order's status using our app.<br />Thank you.");
where:
response
The TEXT response that represents the encoded data. This example returns - Your order is ready. You can track your order's status using our app.<br />Thank you.
"Your order is ready. You can track your order's status using our app.<br />Thank you."
The TEXT that represents the HTML text that will be encoded.