How do you convert hexadecimal to binary?
Hello,
I am working on a project where I need to convert a hexadecimal packet to binary. It is looking like I would use the BinaryEncode function, but I wasn't really sure if that was the right way to go about it or not.
For instance, I need to convert '01DD6300000C0E1012' to '000000011101110101100011000000000000000000001100000011100001000000010010'.
I had thought it would be straight forward such.
<cfset myHex = "01DD6300000C0E1012">
<cfset myBinary = BinaryDecode(myHex, "hex")>
<cfoutput>
<h2>
myHex = #myHex#<br />
myBinary = #myBinary#
</h2>
</cfoutput>
However, I end up getting the following error.
ByteArray objects cannot be converted to strings.
The error occurred in C:\inetpub\wwwroot\playground\hexIT.cfm: line 17
15 : <h2>
16 : myHex = #myHex#<br />
17 : myBinary = #myBinary#
18 : </h2>
19 : </cfoutput>
I was expecting that the result was going to be a string of data and not a ByteArray.
Is there a better way to go about this?
Best regards
KR
