aboutsummaryrefslogtreecommitdiffstats
path: root/filters/syntax-highlighting.py
diff options
context:
space:
mode:
Diffstat (limited to 'filters/syntax-highlighting.py')
-rwxr-xr-xfilters/syntax-highlighting.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/filters/syntax-highlighting.py b/filters/syntax-highlighting.py
index bcf32c8..ec970ab 100755
--- a/filters/syntax-highlighting.py
+++ b/filters/syntax-highlighting.py
@@ -21,6 +21,7 @@
import sys
+import io
from pygments import highlight
from pygments.util import ClassNotFound
from pygments.lexers import TextLexer
@@ -29,8 +30,9 @@ from pygments.lexers import guess_lexer_for_filename
from pygments.formatters import HtmlFormatter
-# read stdin and decode to utf-8. ignore any unkown signs.
-data = sys.stdin.read().decode(encoding='utf-8', errors='ignore')
+sys.stdin = io.TextIOWrapper(sys.stdin.buffer, encoding='utf-8')
+sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
+data = sys.stdin.read()
filename = sys.argv[1]
formatter = HtmlFormatter(encoding='utf-8', style='pastie')