Commits

Jason R. Coombs committed 6a4c517

Allow customization of decoding of incoming lines. Fixes #5.

Comments (0)

Files changed (2)

+3.4
+===
+
+* LineBuffer now allows customization of the decoding (including disabling
+  decoding altogether). To disable decoding of incoming lines, invoke the
+  following at some point before the connection is established::
+
+    irc.client.LineBuffer.decoder = lambda line: line
+
+  This fixes #5.
+
 3.3
 ===
 
     [u'Ol\ufffd']
     """
     line_sep_exp = re.compile(b'\r?\n')
-    encoding = 'utf-8'
+    decoder = lambda line: line.decode('utf-8', 'replace')
 
     def __init__(self):
         self.buffer = b''
         lines = self.line_sep_exp.split(self.buffer)
         # save the last, unfinished, possibly empty line
         self.buffer = lines.pop()
-        return (
-            line.decode(self.encoding, 'replace')
-            for line in lines
-        )
+        return (self.decoder(line) for line in lines)
 
     def __iter__(self):
         return self.lines()