]> granicus.if.org Git - cgit/commitdiff
syntax-highlighting: always use utf-8 to avoid ascii codec issues
authorJason A. Donenfeld <Jason@zx2c4.com>
Mon, 18 Jan 2016 10:14:06 +0000 (11:14 +0100)
committerJason A. Donenfeld <Jason@zx2c4.com>
Mon, 18 Jan 2016 10:14:06 +0000 (11:14 +0100)
filters/syntax-highlighting.py

index b5d615e6231c111b18ede6b3c006840aaae45648..1ca410815a85a980b927f3d412c280937d1ade6e 100755 (executable)
@@ -21,6 +21,7 @@
 
 
 import sys
+import io
 from pygments import highlight
 from pygments.util import ClassNotFound
 from pygments.lexers import TextLexer
@@ -29,6 +30,8 @@ from pygments.lexers import guess_lexer_for_filename
 from pygments.formatters import HtmlFormatter
 
 
+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(style='pastie')