Jason R. Coombs avatar 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()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.