Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,5 @@ def read(filename):
irclogsearch = irclog2html.irclogsearch:main
""",
zip_safe=False,
install_requires=['chardet'],
)
10 changes: 5 additions & 5 deletions src/irclog2html/irclog2html.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
was written by Jeff Waugh and is available at www.perkypants.org
"""

# Copyright (c) 2005--2013, Marius Gedminas
# Copyright (c) 2005--2013, Marius Gedminas
# Copyright (c) 2000, Jeffrey W. Waugh

# Python port:
Expand Down Expand Up @@ -54,6 +54,7 @@
import shlex
import shutil
import sys
import chardet

try:
from urllib import quote
Expand Down Expand Up @@ -138,10 +139,9 @@ def decode(self, s):
if isinstance(s, unicode):
# Accept input that's already Unicode, for convenience
return s
try:
return s.decode('UTF-8')
except UnicodeError:
return s.decode('cp1252', 'replace')
else:
charset = chardet.detect(s)['encoding']
return s.decode(charset, 'replace')

def __iter__(self):
for line in self.infile:
Expand Down