mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-30 06:49:24 +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
|
||||
except UnicodeError:
|
||||
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
|
||||
# offending characters
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user