This is possible with TCL, although to be honest this is one of my biggest struggles with Cloverleaf. Making sure the binary data isn’t corrupted as it’s put into a message with msgset, routed to another threads, possibly read back into TCL with msgget, sent out via an outbound thread seems difficult. You have to keep track of the message encoding settings on the threads that the data passes through. You have to keep track of (and maybe change) the encoding system that TCL uses (see the “encoding system” command in TCL).
For a project that I was working on recently, I had some binary data passing through Cloverleaf that I tried to reencode into base64, and I was never able to figure out why the encoding wouldn’t work. The data would be garbage when it was decoded by the receiver. I ended up coming up with a workaround that didn’t require the encoding. My code was using the tcllib base64 module and not the TCL binary command, so maybe that was part of the problem.
I’ve got some sample code that we run if you want to see how we use it.
set decodedString [base64::decode <your base64 data here>]
if you’re reading a PDF file to be encoded in a message, open the PDF file with binary translation.
set pdfPath /tmp/jeffTestPdf.pdf
set infile [open $pdfPath r]
fconfigure $infile -translation binary
set encodedPdfString [base64::encode [read $infile]]
close $infile
I would first make sure the supplied data is indeed encoded properly. One way I would do that is to locate a utility product that decodes base64 file and see if that produces a viewable PDF.
Here is a link but a search on the Internet should produce a number of free utilities.