TOSTRING | |
Description
Converts a value to a string. |
|
Returns
A string. |
|
Category
Conversion functions, String functions |
|
Function syntaxToString(value[, encoding]) |
|
See also
ToBase64, ToBinary, CharsetEncode; Chapter 35, "Using XML and WDDX," in ColdFusion MX Developer's Guide |
|
History
ColdFusion MX:
|
|
Parameters
|
|
Usage
This function can convert simple values and binary values that do not contain Byte zero. If this function cannot convert a value, it throws an exception. This function can also convert an XML document object to a string XML representation. Macromedia recommends that you use the CharsetEncode function to convert binary data to a string. |
|
Example<h3>ToString Example</h3> <!---- Initialize data. ------> <cfset charData = ""> <!----- Create string of ASCII characters (32-255) and concatenate them. ----> <cfloop index = "data" from = "32" to = "255"> <cfset ch = chr(data)> <cfset charData = charData & ch> </cfloop> <p>The following string is the concatenation of characters (32 to 255) from the ASCII table.<br> <cfoutput>#charData#</cfoutput></p> <!------ Create a Base64 representation of this string. ----> <cfset data64 = toBase64(#charData#)> <p> The following string is the Base64 representation of the string.<br> <cfoutput>#data64#</cfoutput></p> <!---- Create a binary representation of Base64 data. ---> <cfset dataBinary = toBinary(data64)> <!---- Create the string representation of the binary data. -----> <cfset dataString = ToString(dataBinary)> <p>The following is the string representation of the binary data.<br> <cfoutput>#dataString#</cfoutput></p> |
VALUE | |
ENCODING | |