mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 05:09:23 +01:00
String.decode: Only encode('utf-8') when the decode string is unicode
Closes: Sf#3165718 Signed-off-by: James McCoy <jamessan@users.sourceforge.net>
This commit is contained in:
parent
8f7c4bdf7f
commit
01c8dc7f78
@ -79,7 +79,12 @@ class String(callbacks.Plugin):
|
|||||||
<http://docs.python.org/library/codecs.html#standard-encodings>.
|
<http://docs.python.org/library/codecs.html#standard-encodings>.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
irc.reply(text.decode(encoding).encode('utf-8'))
|
s = text.decode(encoding)
|
||||||
|
# Not all encodings decode to a unicode object. Only encode those
|
||||||
|
# that do.
|
||||||
|
if isinstance(s, unicode):
|
||||||
|
s = s.encode('utf-8')
|
||||||
|
irc.reply(s)
|
||||||
except LookupError:
|
except LookupError:
|
||||||
irc.errorInvalid('encoding', encoding)
|
irc.errorInvalid('encoding', encoding)
|
||||||
except binascii.Error:
|
except binascii.Error:
|
||||||
|
Loading…
Reference in New Issue
Block a user