mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 05:09:23 +01:00
Add fallback decoding if chardet fails to guess the correct encoding
This commit is contained in:
parent
4316e5936e
commit
bbdd55bea2
@ -208,6 +208,10 @@ class SocketDriver(drivers.IrcDriver, drivers.ServersMixin):
|
|||||||
# on error, give up and replace the offending characters
|
# on error, give up and replace the offending characters
|
||||||
except UnicodeError:
|
except UnicodeError:
|
||||||
line = line.decode(errors='replace')
|
line = line.decode(errors='replace')
|
||||||
|
else:
|
||||||
|
# if no encoding could be guessed, fall back to utf-8 and
|
||||||
|
# replace offending characters
|
||||||
|
line = line.decode(encoding='utf-8', errors='replace')
|
||||||
# if chardet is not loaded, try to decode using utf-8 and replace any
|
# if chardet is not loaded, try to decode using utf-8 and replace any
|
||||||
# offending characters
|
# offending characters
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user