Accessibility
 
Home > Products > ColdFusion > Support > Getting Started with ColdFusion
ColdFusion Icon Macromedia ColdFusion Support Center - Getting Started with ColdFusion
Escaping (including) special characters inside strings

Since pound signs and quotation marks have special meaning in CFML, you must use a special technique called escaping to include them in your results. Escaping instructs ColdFusion not to use the character for its special meaning, but rather to include the character in the current output.

You include special characters in a string by repeating the special character or enclosing them in quotation marks.

Example Description
<cfset s = 'Ray said, " Hi Mary " ' >

or

<cfset s = "Ray said, "" Hi Mary "">

In both these examples, the value s equals: Ray said, "Hi Mary" because they are enclosed within quotation marks.

<cfoutput>

I saved the shirt with the ##1 on it for you.

</cfoutput>

In this example, a single pound sign is repeated within the cfoutput. The following output is sent to the client: I saved the shirt with the #1 on it for you.


Note, however, you do not need to escape single- or double-quotation marks when using the cfoutput tag. ColdFusion ignores these special meaning characters (quotation marks) inside the cfoutput tag and returns them to the client. For example:

<cfoutput>
"Ray said, "Hi Mary""
</cfoutput>

In this example, the following output is sent the client:

"Ray said, "Hi Mary""

Submit feedback about this tutorial.

To Table of Contents Back to Previous document