[comp.sys.atari.8bit] ABRA-CA-DABRA

jhs@MITRE-BEDFORD.ARPA.UUCP (01/27/87)

The correct first line is:

begin 644 magic.tur
M     68!9P&_ N0]]SU/J%)!24ZD1DE,1:1"4D6H05)4J$U,I$=20:3!54Y/

The only (!) difference I can see is that the space character " " in the
correct version has been turned into "`" (accent grave?) in your version.  It
might be interesting to compare the bit patterns.  If you do a translation
using unix "tr" to make ` into space, you might be all right.

Uuencode is a simple translation to understand, though not easy to implement
in ordinary BASIC.  (It should be relatively easy in Turbo BASIC, though!)
What it does is to take groups of 3 bytes, or 24 bits total, and re-group
them as 4 groups of 6 bits each (still 24 bits).  These 6-bit groups are
then expanded into 8-bit bytes by adding 32 (decimal) so the bytes have values
in the range 32 through 95.

The bytes so formed are grouped into lines, traditionally with 60 or fewer
bytes per line.  Because of the 3-to-4 expansion, each such line corresponds
to 45 bytes of packed binary input.  One more byte is inserted at the
beginning of each uuencoded line.  This byte tells the decoder how many bytes
of output will result from uudecoding that line.  Normally that is 45 bytes.
This number is also transformed by adding 32 (decimal) so it will be a
printing ASCII character.  Adding 32 to the normal value of 45 gives 77,
which is an ASCII capital "M".  Thus the first character of most uuencoded
lines is "M", as you may have noticed.

The last line of the file is usually not precisely filled, i.e., only if the
total number of bytes to be encoded in the input file is divisible by 45.
So most of the time, the last line is shorter than 60 output bytes and
the first character is something less than 77, or a character which comes
before "M" in the ASCII "collating sequence".

Uuencode then inserts a single line with zero bytes converted.  The byte count
character is a space, which is ASCII 32 (decimal), or zero after subtracting
32.

Finally, a line containing the word "end" (3 characters) is tacked on.

I should also mention that the FIRST line of the uuencoded output file starts
with the word "begin", then a space, then the unix protection code to be put
on the output file, and finally the name to be given to the output file.
This enables the uudecoder on a unix system to name the file correctly and set
its protection code correctly.

Interpreting uuencode/decode on an Atari, it would be useful to translate
unix protection codes in some way so that the output file is locked if the
unix code specifies read only, but my uudecoder isn't so fancy.  Also, it
would be useful to name the output file from the name given in the first line
of the uuencoded file if no other name is given at run time.  Maybe in the
final version...

I hope this is of help.

-John Sangster
jhs@mitre-bedford.arpa

gandalf@bradley.UUCP (02/02/87)

One note about this uu..code response...

The source I have for uu..code programs on a UNIX system where
I go to school and on PC-clones written in Turbo Pascal is
that when encoding, if a space (ASCII 32) is to be output to
the coded file a grave (ASCII 96) IS inserted in its place.
The reverse takes place running uudecode.  Therefore I 
question that the correct version would have any spaces in it
at all if the uu..code programs are supposed to be fully
compatible with the UNIX originals.

Bob Greenwald

...!ihnp4!bradley!gandalf