jaraco / irc

Full-featured Python IRC library for Python.
MIT License
390 stars 84 forks source link

encoding outgoing messages seems to remove "\x1d" #211

Closed OrpheusGr closed 11 months ago

OrpheusGr commented 11 months ago

I'm using the following encoding settings:

reactor = irc.client.Reactor()
irc.client.ServerConnection.buffer_class.encoding = "utf-8"
irc.client.ServerConnection.buffer_class.errors = "replace"

I was going crazy trying to find out why sending a message that includes "\x1d" ended up sent to IRC without "\x1d". The really frustrating part is that "\x02" is not removed. This ultimately results to not being able to send messages with italics. I tried removing the irc.client.ServerConnection.buffer_class.errors = "replace" part in hopes that some kind of encoding error occured and "\x1d" was replaced/removed. But that didn't seem to work. Is there some kind of exception i can use for that character to not be stripped?

OrpheusGr commented 11 months ago

Apologies, this was an invalid issue. After further frustration, i found out /x1d is removed when .split() is used on a string, which happens at some point in my code right before the string is passed to privmsg()

(i had to use re.split with a positive lookahead assertion "r'\s+(?=\x1d)'" to split the string with /x1d included)

I apologise, once again for blaming the Library for this as it is a Python thing.