![MACROMEDIA COLFUSION MX 7-CFML Reference Download Page 497](http://html1.mh-extra.com/html/macromedia/colfusion-mx-7-cfml/colfusion-mx-7-cfml_reference_3310974497.webp)
BinaryEncode
497
•
IsBinary
for checking variables for binary format
•
Len
for determining the length of a binary object
Example
The following example reads a GIF file as binary data, converts it to a binary-encoded string,
converts the binary-encoded data back to binary data, and writes the result to a file. It displays the
encoded string and the image in the output file.
<h3>Binary Encoding Conversion Example</h3>
<!--- Do the following if the form has been submitted. --->
<cfif IsDefined("Form.binEncoding")>
<!--- Read in a binary data file. --->
<cffile action="readbinary"
file="C:\CFusionMX7\wwwroot\CFIDE\administrator\images\help.gif"
variable="binimage">
<!--- Convert the read data to binary encoding and back to binary data. --->
<cfscript>
binencode=
BinaryEncode(binimage, Form.binEncoding);
bindecode=BinaryDecode(binencode, Form.binEncoding);
</cfscript>
<!--- Write the converted results to a file. --->
<cffile action="write" file="C:\temp\help.gif" output="#bindecode#"
addnewline="No" >
<!--- Display the results. --->
<cfoutput>
<p><b>The binary encoding:</b> #Form.binEncoding#</p>
<p><b>The image converted into a binary-encoded string by BinaryEncode
</b><br>
#binencode#</p>
<p><b>The image as written back to a file after converting back to binary
using BinaryDecode</b><br>
<img src="C:\temp\help.gif"><br>
</cfoutput>
</cfif>
<!--- The input form. --->
<form action="#CGI.SCRIPT_NAME#" method="post">
<b>Select binary encoding</b><br>
<select size="1" name="binEncoding" >
<option selected>UU</option>
<option>Base64</option>
<option>Hex</option>
</select><br>
<br>
<input type = "Submit" value = "convert my data">
</form>
Summary of Contents for COLFUSION MX 7-CFML
Page 1: ...COLDFUSION MX7 CFML Reference...
Page 20: ...20 Chapter 1 Reserved Words and Variables...
Page 50: ...50 Chapter 2 ColdFusion Tags cfelse br Searching cfif cfloop cfif...
Page 101: ...cfdefaultcase 101 cfdefaultcase cfswitch cfoutput Your grade is grade cfoutput...
Page 115: ...cfdocumentsection 115 cfdocumentsection cfoutput cfdocument...
Page 411: ...cftable 411 cftable body html...
Page 515: ...Chr 515 maxlength 5 p input type Submit name input type RESET cfform...
Page 605: ...GetEncoding 605 WriteOutput The encoding is theEncoding cfscript cfif...
Page 629: ...GetProfileString 629 tr td input type Submit name Submit value Submit td td td tr table form...
Page 655: ...IIf 655 cfoutput IIf Hour Now GTE 12 DE It is afternoon or evening DE It is morning cfoutput b...
Page 664: ...664 Chapter 3 ColdFusion Functions cfelse h3 Conversion error h3 cfif...
Page 687: ...IsStruct 687 cfoutput cfquery cfif cfoutput hr Employee Add Complete cfoutput cfcase cfswitch...
Page 751: ...LSDateFormat 751 hr noshade cfoutput cfloop...
Page 861: ...StructFind 861 cfquery cfif cfoutput hr Employee Add Complete cfoutput cfcase cfswitch...
Page 903: ...Val 903 value Is the beginning numeric name form...
Page 932: ...932 Chapter 3 ColdFusion Functions...
Page 944: ...944 Chapter 4 ColdFusion MX Flash Form Style Reference...
Page 962: ...962 Chapter 5 Application CFC Reference...
Page 1054: ...1054 Chapter 6 ColdFusion MX Event Gateway Reference...