uuencode help
Martin von Loewis
loewis at informatik.hu-berlin.de
Mon Sep 10 10:07:48 EDT 2001
dcook at redhat.com (David M. Cook) writes:
> A python script to generate a uuencoded file:
>
> import uu
> import os
>
> filename = "/usr/games/chromium/data/png/chrome.jpg"
> infile = open(filename, "r")
> outfile = open("/tmp/chrome.uu", "w")
> uu.encode(infile, outfile, os.path.basename(filename), 0644)
Thanks. I've researched that a little further, and found that this is
likely a bug in the Linux uuencode. According to the Single Unix
definition of uuencode, at
http://www.opengroup.org/onlinepubs/7908799/xcu/uuencode.html
the range of characters used is ASCII 0x20-0x5f, whereas Linux
uuencode apparently uses 0x21-0x60 (with 0x60 representing a value of
0). This appears to be the BSD definition of the uuencode format, see
http://www.tac.eu.org/cgi-bin/man-cgi?uuencode+5
Please have a look at
http://www.utexas.edu/ftp/gifstuff/uutools/uuencode.txt
which elaborates the rationale for this deviation. Also note that
either encoding decodes properly, as you can mask each character with
0x3F, to get the encoded value.
So in short, no need to worry. If you want your code to work like the
Linux/BSD uuencode, you should replace all 0x20 characters inside the
encoded text with 0x60.
Regards,
Martin
More information about the Python-list
mailing list