commit 4b01ababb5f9a145d44420df51e2ae6ffdf1f6df parent 05a2adf0a899ff7e858751c0d84f6e467cb8205e Author: Antoine Amarilli <a3nm@a3nm.net> Date: Mon, 11 Jun 2012 19:52:21 +0200 add ircfilter.py Diffstat:
ircfilter.py | | | 22 | ++++++++++++++++++++++ |
1 file changed, 22 insertions(+), 0 deletions(-)
diff --git a/ircfilter.py b/ircfilter.py @@ -0,0 +1,22 @@ +#!/usr/bin/python3 -u + +"""Convert from latin1 or utf8 to utf8""" + +import sys + +sys.stdin = sys.stdin.detach() +sys.stdout = sys.stdout.detach() + +try: + while True: + l = sys.stdin.readline() + if not l: + break + try: + line = l.decode('utf8') + except UnicodeDecodeError: + line = l.decode('latin1') + sys.stdout.write(line.encode('utf8')) +except IOError: + pass +