STINNER Victor <[EMAIL PROTECTED]> added the comment: I think that telnet should only use bytes (and not characters). For an HTTP connection, the charset is only known after parsing the HTTP headers. So telnet should use bytes, and your HTTP browser will convert bytes to characters using the charset from the HTTP headers. My patch only uses bytes for internal buffering and special codes (IAC, DONT, ENCRYPT, etc.).
Example to test the library (Starwars, telnet, ISO-8859-1): from telnetlib import Telnet from sys import stdout ipv4 = "towel.blinkenlights.nl" ipv6 = "2001:980:ffe:1::42" t = Telnet(ipv6, 23) while True: command = t.read_some() command = str(command, "ISO-8859-1") stdout.write(command) Example to test the library (Google, HTTP, ASCII): from telnetlib import Telnet t = Telnet("www.google.com", 80) t.write(b'GET / HTTP/1.0\r\n\r\n') answer = t.read_all() answer = str(answer, "ASCII") print(answer) ---------- keywords: +patch nosy: +haypo Added file: http://bugs.python.org/file11788/telnet_bytes.patch _______________________________________ Python tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue3725> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com