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.
- 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.
<response> = <data>.htmlEncode();
<response> = htmlEncode(<data>);
Specifies the response that represents the encoded HTML data
Specifies the HTML text that will be encoded.
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.");
"Your order is ready. You can track your order's status using our app.<br />Thank you."