Index: legacy/glue.py =================================================================== --- legacy/glue.py (revision 86) +++ legacy/glue.py (working copy) @@ -7,6 +7,7 @@ import config import debug import lang +import locale # The name of the transport name = "ICQ Transport" Index: legacy/icqt.py =================================================================== --- legacy/icqt.py (revision 84) +++ legacy/icqt.py (working copy) @@ -12,6 +12,7 @@ import sys, warnings, pprint import stats import lang +import locale ############################################################################# @@ -121,7 +122,7 @@ if (multiparts[0][1] in ['unicode','utf-8']): encoding = "utf-8" else: - encoding = config.encoding + encoding = multiparts[0][1] else: encoding = config.encoding debug.log("B: using encoding %s" % (encoding)) Index: jabw.py =================================================================== --- jabw.py (revision 75) +++ jabw.py (working copy) @@ -5,11 +5,11 @@ from tlib.jabber import jid import utils import debug +import locale - def sendMessage(pytrans, to, fro, body, mtype=None, errorType=None, delay=None): """ Sends a Jabber message """ - debug.log("jabw: Sending a Jabber message \"%s\" \"%s\" \"%s\" \"%s\"" % (to, fro, utils.latin1(body), mtype)) + debug.log("jabw: Sending a Jabber message \"%s\" \"%s\" \"%s\" \"%s\"" % (to, fro, body, mtype)) el = Element((None, "message")) el.attributes["to"] = to el.attributes["from"] = fro @@ -33,7 +33,7 @@ x.attributes["stamp"] = delay b = el.addElement("body") - b.addContent(utils.utf8encode(body)) + b.addContent(body) x = el.addElement("x") x.attributes["xmlns"] = "jabber:x:event" composing = x.addElement("composing") @@ -47,10 +47,10 @@ el.attributes["type"] = ptype if(show): s = el.addElement("show") - s.addContent(utils.utf8encode(show)) + s.addContent(show) if(status): s = el.addElement("status") - s.addContent(utils.utf8encode(status)) + s.addContent(status) if(priority): s = el.addElement("priority") s.addContent(priority) @@ -121,7 +121,7 @@ For this message to be an error, mtype="error", errorType=("modify", "bad-request", "Human readable descriptive text") - See XMPP Core (RFC3920) for more details For this message to have a you must pass a correctly formatted timestamp (See JEP0091) """ - debug.log("User: %s - JabberConnection sending message \"%s\" \"%s\" \"%s\" \"%s\"" % (self.jabberID, to, fro, utils.latin1(body), mtype)) + debug.log("User: %s - JabberConnection sending message \"%s\" \"%s\" \"%s\" \"%s\"" % (self.jabberID, to, fro, body, mtype)) sendMessage(self.pytrans, to, fro, body, mtype, errorType, delay) def sendErrorMessage(self, to, fro, etype, eelement, econtent, body=None): @@ -194,10 +194,9 @@ self.typingNotificationReceived(toj.userhost(), toj.resource, composing) if(body): -# body = utils.utf8(body) # Save the message ID for later self.messageIDs[to] = mID - debug.log("User: %s - JabberConnection parsed message packet \"%s\" \"%s\" \"%s\" \"%s\" \"%s\"" % (self.jabberID, froj.userhost(), to, froj.resource, mtype, utils.latin1(body))) + debug.log("User: %s - JabberConnection parsed message packet \"%s\" \"%s\" \"%s\" \"%s\" \"%s\"" % (self.jabberID, froj.userhost(), to, froj.resource, mtype, body)) self.messageReceived(froj.userhost(), froj.resource, toj.userhost(), toj.resource, mtype, body) def onPresence(self, el): Index: main.py =================================================================== --- main.py (revision 86) +++ main.py (working copy) @@ -5,8 +5,11 @@ import getopt import sys import os +import locale + reload(sys) -sys.setdefaultencoding('iso-8859-1') +locale.setlocale(locale.LC_ALL, "") +sys.setdefaultencoding(locale.getpreferredencoding()) del sys.setdefaultencoding if (float(sys.version[:3]) < 2.3): Index: debug.py =================================================================== --- debug.py (revision 72) +++ debug.py (working copy) @@ -5,6 +5,7 @@ import config import utils import time +import locale """ A simple logging module. Use as follows. @@ -28,15 +29,19 @@ def log(data, wtime=True): if(wtime): debugFile.write(time.strftime("%D - %H:%M:%S - ")) - #debugFile.write(utils.latin1(data) + "\n") - debugFile.write(data + "\n") + try: + debugFile.write(data + "\n") + except UnicodeEncodeError: + debugFile.write(data.encode(locale.getpreferredencoding(),'replace') + "\n") debugFile.flush() else: def log(data, wtime=True): if(wtime): print time.strftime("%D - %H:%M:%S - "), - #print utils.latin1(data) - print data + try: + print data + except UnicodeEncodeError: + print data.encode(locale.getpreferredencoding(),'replace') log("Debug logging enabled.") else: def log(data):