From: Charlie Bursell on
I must be doing something dumb but can't figure out what it is.

I wanted to validate that the tcllib version of uuencode/uudecode
would work so I used the GNU command line uuencode to encode a simple
PDF document,

I then read that uuencoded file into tcl using fcongiure -translation
binary and run it throug uuencoeLLdecode and even uuencode::uudecode
and write the output to a file.

I would expect the decoded file to be the same PDF file I originaly
encoded but it is not even close,

For example, the first few line of the proper PDF file look like:
%PDF-1.2
%Γπ╧╙
2 0 obj
<<
/D [1 0 R /XYZ null 895 null]
>>

What I get from the tcllib decode is something like:

QÉ8♣?@♀?d?gT?♣9☺♠ª?U♦Db?↕? ¢^.<?0?£"♥☻♠ö& £??¢ôB♣?↕♥☻♣"☻???¢♠çV??l 895
null]
>>
endobj
3 0 obj
<<
/D [1 0 R /Xª??¢♠çVÆ?♥‼?r♠çVÆÅ?£?à?VæFö& £B♥☻♠ö& £??¢ôB♣?↕

Can anyone put me on the right track?
From: Andreas Leitgeb on
Charlie Bursell <cbursell(a)geusnet.com> wrote:
> I must be doing something dumb but can't figure out what it is.
> I wanted to validate that the tcllib version of uuencode/uudecode
> would work so I used the GNU command line uuencode to encode a simple
> PDF document,
>
> I then read that uuencoded file into tcl using fcongiure -translation
> binary and run it throug uuencoeLLdecode and even uuencode::uudecode
> and write the output to a file.

I guess the mistake happened when writing back to file.

I tried this (with some xyz.pdf):
on unix shell:
uuencode xyz.pdf xyz.pdf > xyz.uu
in tclsh:
package require uuencode
set x [uuencode::uudecode -file xyz.uu]; llength $x;# -> 1
this $x is a list of entries of the uu-file
set y [lindex $x 0]; llength $y
this $y is a three element list describing that entry
set z [lindex $y 2]; string length $z
this $z now is the binary content of the original pdf
now write it back to file:
open out.pdf w ;# gave me file5
fconfigure file5 -translation binary
puts -nonewline file5 $z; close file5
and back in unix shell:
diff out.pdf xyz.pdf ;# -> equal

> I would expect the decoded file to be the same PDF file I originaly
> encoded but it is not even close,

Normally, a safe bet.

If you did essentially the same, but still get rubbish, then post the
first six lines of the uuencoded text, (but NOT the complete uu!!),
so we can see, if something went completely wrong in encoding.

From: Charlie Bursell on
On Apr 2, 11:59 am, Andreas Leitgeb <a...(a)gamma.logic.tuwien.ac.at>
wrote:
> Charlie Bursell <cburs...(a)geusnet.com> wrote:
> > I must be doing something dumb but can't figure out what it is.
> > I wanted to validate that the tcllib version of uuencode/uudecode
> > would work so I used the GNU command line uuencode to encode a simple
> > PDF document,
>
> > I then read that uuencoded file into tcl using fcongiure -translation
> > binary and run it throug uuencoeLLdecode and even uuencode::uudecode
> > and write the output to a file.
>
> I guess the mistake happened when writing back to file.
>
> I tried this (with some xyz.pdf):
>  on unix shell:
>    uuencode xyz.pdf xyz.pdf > xyz.uu
>  in tclsh:
>    package require uuencode
>    set x [uuencode::uudecode -file xyz.uu]; llength $x;# -> 1
>  this $x is a list of entries of the uu-file
>    set y [lindex $x 0]; llength $y
>  this $y is a three element list describing that entry
>    set z [lindex $y 2]; string length $z
>  this $z now is the binary content of the original pdf
>  now write it back to file:
>    open out.pdf w  ;# gave me file5
>    fconfigure file5 -translation binary
>    puts -nonewline file5 $z; close file5
>  and back in unix shell:
>    diff out.pdf xyz.pdf  ;# -> equal
>
> > I would expect the decoded file to be the same PDF file I originaly
> > encoded but it is not even close,
>
> Normally, a safe bet.
>
> If you did essentially the same, but still get rubbish, then post the
> first six lines of the uuencoded text, (but NOT the complete uu!!),
> so we can see, if something went completely wrong in encoding.

I think I may have figured it out some what

The command "uuencode::uudecode $file" returns a list of lists where
the first list is a single element list and the next contains 3
elements

So doing something like this seems to work:

set lst [lindex [uuencode::uudecode $file] 0]
set Filename [lindex $lst 0]
set perms [lindex $lst 1]
set data [lindex $lst 2]

I never could get anything going with uuencode::decode. Perhaps this
is just for single simple strings?

Thanks for the response