
45
DEVELOPING
COLDFUSION 9 APPLICATIONS
The CFML Programming Language
Las
t
upda
te
d 8/5/2010
How ColdFusion stores dates and times
ColdFusion stores and manipulates dates and times as
date-time objects
. Date-time objects store data on a timeline as
real numbers. This storage method increases processing efficiency and directly mimics the method used by many
database systems. In date-time objects, one day is equal to the difference between two successive integers. The time
portion of the date-and-time value is stored in the fractional part of the real number. The value 0 represents 12:00 AM
12/30/1899.
Although you can use arithmetic operations to manipulate date-and-time values directly, this method can result in
code that is difficult to understand and maintain. Use the ColdFusion date-time manipulation functions instead. For
information on these functions, see the
CFML Reference
.
Binary data type and binary encoding
Binary
data (also referred to as a
binary object
) is raw data, such as the contents of a GIF file or an executable program
file. You do not normally use binary data directly, but you can use the
cffile
tag to read a binary file into a variable,
typically for conversion to a string binary encoding before transmitting the file using e-mail.
A string binary encoding represents a binary value in a string format that can be transmitted over the web. ColdFusion
supports three binary encoding formats:
ColdFusion provides the following functions that convert among string data, binary data, and string encoded binary
data:
Complex data types
Arrays, structures, and queries are ColdFusion built-in complex data types. Structures and queries are sometimes
referred to as objects, because they are containers for data, not individual data values.
For details on using arrays and structures, see “
Using Arrays and Structures
” on page 82.
Encoding
Format
Base64
Encodes the binary data in the lowest six bits of each byte. It ensures that binary data and non-ANSI character data
can be transmitted using e-mail without corruption. The Base64 algorithm is specified by IETF RFC 2045, at
www.ietf.org/rfc/rfc2045.txt
.
Hex
Uses two characters in the range 0-9 and A-F represent the hexadecimal value of each byte; for example, 3A.
UU
Uses the UNIX UUencode algorithm to convert the data.
Function
Description
BinaryDecode
Converts a string that contains encoded binary data to a binary object.
BinaryEncode
Converts binary data to an encoded string.
CharsetDecode
Converts a string to binary data in a specified character encoding.
CharsetEncode
Converts a binary object to a string in a specified character encoding.
ToBase64
Converts string and binary data to Base64 encoded data.
ToBinary
Converts Base64 encoded data to binary data. The BinaryDecode function provides a superset of the ToBase64
functionality.
ToString
Converts most simple data types to string data. It can convert numbers, date-time objects, and Boolean values. (It
converts date-time objects to ODBC timestamp strings.) Adobe recommends that you use the CharsetEncode
function to convert binary data to a string in new applications.