Chris Green wrote: > To add a little to this, the problem is definitely when I receive a > message with UTF8 (or at least non-ascci) characters in it. My code > is basically very simple, the main program reads an E-Mail message > received from .forward on its standard input and makes it into an mbox > message as follows:- > > msg = mailbox.mboxMessage(sys.stdin.read()) > > it then does various tests (but doesn't change msg at all) and at the > end delivers the message to my local mbox with:- > > mbx.add(msg) > > where mbx is an instance of mailbox.mbox. > > > So, how is one supposed to handle this, should I encode the incoming > message somewhere? >
This is what I'd try. Or just read the raw bytes: data = sys.stdin.detach().read() msg = mailbox.mboxMessage(data) -- https://mail.python.org/mailman/listinfo/python-list