I've already searched and came across some really old posts, but we're having an interesting issue with changing the encoding from a uuencoded PDF to a base64 encoded PDF. We've run into some 'interesting' things. This is passing a field into a xltp (ZRI3.5 for those in the know):
The code:
- package require base64
- package require uuencode
- set index0 [lindex $xlateInVals 0]
- set index0 [string map { \\X0D\\\\X0A\\ \n \\F\\ | \\S\\ ^ \\T\\ & \\R\\ ~ \\E\\ \\ } $index0]
- set index0 [join [lrange [split $index0 \n] 1 end] \n]
- set ucode $index0
- set PDF [uuencode::decode $ucode]
- set b64 [base64::encode $PDF]
- set xlateOutVals [list [base64::encode $PDF]]
So a few interesting notes I've noticed while working on this:
- The uuencode::decode doesn't want the 'begin' line. It puts it into the output of the PDF, this is why I have the line that splits the file after conversion, line 5. If I don't do that, it adds a series of characters the PDF doesn't need.
- If I comment outline 5, I get a full: CHFJOAWUUA3h20Kh0tqtJVBER
- no matter what I do, in the end, the base64 encoded data has an extra character (tJVBER).
- If I leave both the CR and LF characters, (string map { \\X0D\\\\X0A\\ \r\n }) I get even more extra characters at the start (tqtJBVER)
The uuencoding looks fine, no extra characters, and coverts properly to the PDF I'm expecting in the PDF file.
There are some extraneous lines (setting variables to each other) as we were splitting things apart and debugging. I feel like I'm missing something simple here.