mybin

my ~/bin
git clone https://a3nm.net/git/mybin/
Log | Files | Refs | README

ircfilter.py (384B)


      1 #!/usr/bin/python3 -u
      2 
      3 # TODO: should remove non-printable chars
      4 
      5 import sys
      6 
      7 sys.stdin = sys.stdin.detach()
      8 sys.stdout = sys.stdout.detach()
      9 
     10 try:
     11   while True:
     12     l = sys.stdin.readline()
     13     if not l:
     14       break
     15     try:
     16       line = l.decode('utf8')
     17     except UnicodeDecodeError:
     18       line = l.decode('latin1')
     19     sys.stdout.write(line.encode('utf8'))
     20 except IOError:
     21   pass