wikifirc

filter irc.wikimedia.org on specific pages and users
git clone https://a3nm.net/git/wikifirc/
Log | Files | Refs | README

ircfilter.py (385B)


      1 #!/usr/bin/python3 -u
      2 
      3 """Convert from latin1 or utf8 to utf8"""
      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
     22