From 2a9b8c71fd8af9c7662d237f1cbdaccc91dc2de3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?La=CC=81szlo=CC=81=20Ka=CC=81rolyi?= Date: Thu, 7 May 2015 13:23:37 +0200 Subject: [PATCH] Fix utf8 stdin --- email-responder.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/email-responder.py b/email-responder.py index 2ef4409..80e9b40 100755 --- a/email-responder.py +++ b/email-responder.py @@ -2,6 +2,7 @@ import sys import os +import io import smtplib import sqlite3 import datetime @@ -17,8 +18,8 @@ from email.utils import parseaddr my_dir = os.path.dirname(os.path.realpath(__file__)) os.chdir(my_dir) - -original_headers = Parser().parsestr(sys.stdin.read()) +stdin_utf8 = io.TextIOWrapper(sys.stdin.buffer, encoding='utf-8') +original_headers = Parser().parsestr(stdin_utf8.read()) # with open('email1.txt') as fp: # original_headers = Parser().parsestr(fp.read())