From f469a4e347de360585d03a1defb3a5f99e2b3d1f Mon Sep 17 00:00:00 2001 From: jesopo Date: Tue, 3 Mar 2020 11:44:00 +0000 Subject: [PATCH] use codecs.iterencode() to generator-style iterate encoding a string --- src/IRCLine.py | 6 +++--- 1 file 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] == " ":