Adobe ColdFusion 8

IsBinary

Description

Determines whether a value is stored as binary data.

Returns

True, if the value is binary; False, otherwise.

Category

Decision functions

Function syntax

IsBinary(value)

See also

ToBinary, ToBase64, IsNumeric, YesNoFormat

Parameters

Parameter

Description

value

Number or string

Example

<!--- Create a string of all ASCII characters (32-255) 
 and concatenate them together. --->
<cfset charData ="">
<cfloop index="data" from="32" to="255">
    <cfset ch=chr(data)>
    <cfset charData=charData & ch>
</cfloop>

<b>The following string is the concatenation of all characters (32 to 255) from the ASCII table.</b><br><br>
<cfoutput>#htmleditformat(charData)#</cfoutput>
<br><br>
<!--- Create a Base 64 representation of this string. --->
<cfset data64=toBase64(charData)>
<!--- Convert string to binary. --->
<cfset binaryData=toBinary(data64)>
<!--- Check to see if it really is a binary value. --->
<cfif IsBinary(binaryData)>
The binaryData variable is binary!<br>
</cfif>
<!--- Convert binary data back to Base 64. --->
<cfset another64=toBase64(binaryData)>
<cfif Not IsBinary(another64)>
The another64 variable is NOT binary!<br>
</cfif>
<!--- Compare another64 with data64 to ensure that they are equal. --->
<cfif another64 eq data64>
    Base 64 representation of binary data is identical to the Base 64 
    representation of string data.
<cfelse>
    <h3>Conversion error.</h3>
</cfif>