
60
Chapter 3: Using ColdFusion Variables
How ColdFusion stores dates and times
ColdFusion stores and manipulates dates and times as
date-time objects
. Date-time objects store
data on a time line as real numbers. This storage method increases processing efficiency and
directly mimics the method used by many popular 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 Base64 encoding
Binary
data 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 Base64 encoding before transmitting the file using e-mail.
Base64
format encodes the 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 MIME
specification defines the Base64 encoding method.
ColdFusion does not have a Base64 data type; it processes Base64 encoded data as string data.
ColdFusion provides the following functions that convert among string data, binary data, and
Base64 encoded string data:
The
ToString
function cannot convert Base64 encoded data directly to an unencoded string. Use
the following procedure to convert Base64 encoded data that was originally a string back to a
readable string:
1
Use the
ToBinary
function to convert the Base64 data into binary format.
2
Use the
ToString
function to convert the binary data to string data.
For example, the following two lines print the same results:
<cfoutput>Hello world</cfoutput>
<cfoutput>#ToString(ToBinary(ToBase64("Hello world")))#</cfoutput>
Do not use binary data or Base64 data directly in ColdFusion expressions.
Function
Description
ToBase64
Converts string and binary data to Base64 encoded data.
ToBinary
Converts Base64 encoded data to binary data.
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.) It cannot convert binary data that includes bytes that are not printable
characters.
Содержание COLDFUSION MX 61-DEVELOPING COLDFUSION MX
Страница 1: ...Developing ColdFusion MX Applications...
Страница 22: ...22 Contents...
Страница 38: ......
Страница 52: ...52 Chapter 2 Elements of CFML...
Страница 162: ......
Страница 218: ...218 Chapter 10 Writing and Calling User Defined Functions...
Страница 250: ...250 Chapter 11 Building and Using ColdFusion Components...
Страница 264: ...264 Chapter 12 Building Custom CFXAPI Tags...
Страница 266: ......
Страница 314: ...314 Chapter 14 Handling Errors...
Страница 344: ...344 Chapter 15 Using Persistent Data and Locking...
Страница 349: ...About user security 349...
Страница 357: ...Security scenarios 357...
Страница 370: ...370 Chapter 16 Securing Applications...
Страница 388: ...388 Chapter 17 Developing Globalized Applications...
Страница 408: ...408 Chapter 18 Debugging and Troubleshooting Applications...
Страница 410: ......
Страница 426: ...426 Chapter 19 Introduction to Databases and SQL...
Страница 476: ...476 Chapter 22 Using Query of Queries...
Страница 534: ...534 Chapter 24 Building a Search Interface...
Страница 556: ...556 Chapter 25 Using Verity Search Expressions...
Страница 558: ......
Страница 582: ...582 Chapter 26 Retrieving and Formatting Data...
Страница 668: ......
Страница 734: ...734 Chapter 32 Using Web Services...
Страница 760: ...760 Chapter 33 Integrating J2EE and Java Elements in CFML Applications...
Страница 786: ...786 Chapter 34 Integrating COM and CORBA Objects in CFML Applications...
Страница 788: ......
Страница 806: ...806 Chapter 35 Sending and Receiving E Mail...