aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar jesopo2020-03-03 11:44:00 +0000
committerGravatar jesopo2020-03-03 11:44:00 +0000
commitf469a4e347de360585d03a1defb3a5f99e2b3d1f (patch)
tree59116ef7dcf732ab2727588e875cc8ef41db8a12
parentrewrite command output truncation (diff)
signature
use codecs.iterencode() to generator-style iterate encoding a string
-rw-r--r--src/IRCLine.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/IRCLine.py b/src/IRCLine.py
index 7c041b1e..d6e31f3b 100644
--- a/src/IRCLine.py
+++ b/src/IRCLine.py
@@ -1,4 +1,4 @@
-import datetime, typing, uuid
+import codecs, datetime, typing, uuid
from src import EventManager, IRCObject, utils
# this should be 510 (RFC1459, 512 with \r\n) but a server BitBot uses is broken
@@ -150,8 +150,8 @@ class SendableLine(ParsedLine):
overflow: typing.Optional[str] = None
if (n+len(arg.encode("utf8"))) > LINE_MAX:
- for i, char in enumerate(arg):
- n += len(char.encode("utf8"))
+ for i, char in enumerate(codecs.iterencode(arg, "utf8")):
+ n += len(char)
if n > LINE_MAX:
arg, overflow = arg[:i], arg[i:]
if human_trunc and not overflow[0] == " ":