How to replace special character in a string with their HTML escaped equivalents in ColdFusion

HTMLCodeFormat() - replace special character in a string with their HTML escaped equivalents

HTMLCodeFormat.cfm


<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>HTMLCodeFormat function example: how to replace special character in a string with their HTML escaped equivalents</title>
</head>

<body>
<h2 style="color:hotpink">HTMLCodeFormat Function Example</h2>

<cfset MyString="<b>This is a bold text</b>
This is another line">
<cfoutput>
MyString: #MyString#
<br /><br /><br />
MyString[HTMLCodeFormat]: #HTMLCodeFormat(MyString,3.2)#
</cfoutput>
</body>
</html>





More ColdFusion examples