Hi Gilles,
I do not think this is going to be possible with native CognosScript code. To accomplish the converion to binary, you would need to create a byte array. Unfortunately there is no Byte datatype in CognosScript.
Alternatively, you could create a VB COM dll that would perform the conversion for you. If you have VB, let me know and I'll help code a solution.
/R