1

I have a program reading stdin using by sys.stdin.read(). The stdin is an email given by postfix .forward. Sometimes UnicodeDecodeError occurs (See blow).

How should I read email content with python from stdin?

raw_email = sys.stdin.read()

  File "/app/Python-3.4.2/lib/python3.4/codecs.py", line 313, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf6 in position 1230: invalid start byte
DeepSpace
  • 78,697
  • 11
  • 109
  • 154
user262837
  • 11
  • 1
  • http://stackoverflow.com/questions/16549332/python-3-how-to-specify-stdin-encoding You need to know what the encoding is. – pvg Dec 11 '15 at 20:58
  • Perhaps the mime parsers will be more tolerant of different encodings: http://stackoverflow.com/questions/8312001/python-postfix-stdin – Alastair McCormack Dec 20 '15 at 19:54

0 Answers0