At times while coding in ColdFusion and working with strings, it becomes a headache to escape single or double quotes with in a string. For this we may use below written way to manage.
<cfset variables.event = "Hari's first pen." /> OR else
<cfset variables.event = 'Hari is 5" tall.' />
Both the above ways of escaping single or double quotes works fine when we are using a single quote with in double quotes or vice versa. But think of the situation when you need to write a single quote with in single quotes or a double quote with in double quotes, then the above way will not work.
Escaping a single quote with in single quotes:
<!--- Here I have put two single quotes between Hari and s --->
<cfset variables.event = 'Hari''s first pen.' />
It will print as: Hari’s first pen.
<!--- Here I have put two single quotes around amnesia --->
<cfset variables.event = 'what you told the meaning of ''amnesia'' word?'/>
It will print as: what you told the meaning of ‘amnesia’ word?
Escaping a double quote with in double quotes:
We can escape double quotes in a similar way as above, by writing two double quotes together.