Description
Converts a value to a string.
Returns
A string.
Category
Conversion functions, String functions
Function syntax
ToString(value[, encoding]) |
See also
ToBase64, ToBinary, CharsetEncode; Using XML and WDDX in the Developing ColdFusion Applications
History
ColdFusion MX:
- Changed Unicode support: ColdFusion supports the Java UCS-2 representation of Unicode character values 0-65535. (ColdFusion 5 and earlier releases supported ASCII values 1-255.)
- Added the encoding parameter.
- Added ability to convert an XML document object to a string.
Parameters
Parameter |
Description |
---|---|
value |
Value to convert to a string; can be a simple value such as an integer, a binary object, or an XML document object. |
encoding |
The character encoding (character set) of the string. Optional for binary data, Generates an error if used for a simple value or XML document object.The following list includes commonly used values:
|
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.Adobe recommends that you use the CharsetEncode function to convert binary data to a string.
Example
<cfscript> myString="Hello ColdFusion, how are you?" base64Value = toBase64(myString) binaryValue = toBinary(base64Value) stringValue = toString(binaryValue); writeOutput(stringValue); </cfscript>