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