I have added the following to the Birminhgam local extension to pop-11
http://www.cs.bham.ac.uk/research/poplog/auto/mimencode.p
http://www.cs.bham.ac.uk/research/poplog/auto/mimedecode.p
These provide basic facilities for producing a BASE64 encoded version of
a file, and for decoding such a file. They can be used to produce
attachments to go with mail files, or to decode such attachments.
Better than uuencode/uudecode partly because not all systems support
them and because uuencode can produce trailing spaces causing
confusions.
Better than binhex - not everyone can decode binhex.
1. The first file defines this procedure:
mimeencode(input, output);
input is a string, representing a file name, or a character repeater.
output is a string, representing a file name, or a character consumer.
8 bit characters from input are read in three at a time, the 24 bits
divided into four groups of 6 bits, the 6 bits encoded using the base 64
algorithm, and four 6 bit printable characters are output. After every
72 characters a newline is output.
If the last block of characters contains fewer than three, then padding with
zeros is used to output two or three six bit characters, as appropriate, and
one or two `=` characters output to complete the group of four.
See RFC 2045
2. The second file defines the reverse procedure:
mimedecode(input, output);
input is a string, representing a file name, or a character repeater.
output is a string, representing a file name, or a character consumer.
6 bit characters from input are read in four at a time, decoded, and then
output as three 8 bit characters. Newlines are ignored.
The final group of four characters may end with one or two = signs, and
in that case have to treated specially. If there is only one `=`, then
use the first three characters to generate two characters to be output.
If there are two `=` signs, then use only the first two characters to
generate one character to be output.
Comments and suggestions welcome.
Later ved_send will be extended to use mimencode to produce attachments,
and ved_decode will be extended to use mimedecode to decode base64
attachments to mail messages (in case you don't have mimencode -u)
I don't suppose anyone has written a procedure to decode
Printed-quotable text?
Aaron
===
Aaron Sloman, ( http://www.cs.bham.ac.uk/~axs/ )
School of Computer Science, The University of Birmingham, B15 2TT, UK
EMAIL A.Sloman AT cs.bham.ac.uk (ReadATas@please !)
PAPERS: http://www.cs.bham.ac.uk/research/cogaff/
TOOLS: http://www.cs.bham.ac.uk/research/poplog/freepoplog.html
|