Message 59609 - Python tracker
You're correct in pointing out that IMAP4 supports arbitrary encodings, so simply hard-coding ASCII is not correct. The encoding isn't connection-level, but applies to particular sequences of bytes in the connection stream. To correctly interpret the bytes as characters, decoding must be integrated with the rest of the protocol implementation.