Strings
In
ColdFusion, text values are stored in strings. You specify
strings by enclosing them in either single- or double-quotation
marks. For example, the following two strings are equivalent:
"This is a string"
'This is a string'
You can write an empty string in the following ways:
Strings can be any length, limited by the amount of available
memory on the ColdFusion server. However, the default size limit
for long text retrieval (CLOB) is 64K. The ColdFusion Administrator
lets you increase the limit for database string transfers, but doing
so can reduce server performance. To change the limit, select the
Enable retrieval of long text option on the Advanced Settings page
for the data source.
Escaping quotation marks and number signs
To include a single-quotation character in a string that
is single-quoted, use two single-quotation marks (known as escaping
the single-quotation mark). The following example uses escaped single-quotation
marks:
<cfset myString='This is a single-quotation mark: '' This is a double-quotation mark: "'>
<cfoutput>#mystring#</cfoutput><br>
To include a double-quotation mark in a double-quoted string,
use two double-quotation marks (known as escaping the double-quotation
mark). The following example uses escaped double-quotation marks:
<cfset myString="This is a single-quotation mark: ' This is a double-quotation mark: """>
<cfoutput>#mystring#</cfoutput><br>
Because strings can be in either double-quotation marks or single-quotation marks,
both of the preceding examples display the same text:
This is a single-quotation mark: ' This is a double-quotation
mark: "
To insert a number sign (#) in a string, you must escape the
number sign, as follows:
"This is a number sign ##"