I've got problem sending utf8-encoded text. Here is the
relevant traceback (test_client.py is self-modified
version):
File "./test_client.py", line 122, in sendMessage
self.conn.send(msg)
File "/usr/lib/python2.3/site-packages/jabber.py", line
246, in send
xmlstream.Client.write(self,ustr(what))
File "/usr/lib/python2.3/site-packages/jabber.py", line
184, in ustr
try: r = what.__str__()
File "/usr/lib/python2.3/site-packages/xmlstream.py",
line 176, in __str__
return self._xmlnode2str()
File "/usr/lib/python2.3/site-packages/xmlstream.py",
line 193, in _xmlnode2str
s = s + a._xmlnode2str(parent=self)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3
in position 59: ordinal not in range(128)
The text I'm trying to send includes latin-1 or other
non-ascii characters. The error starts with the first value
which goes over the ascii range. Here it happens to be ö
(ouml), which is hex c3b6 in utf8. The same thing
happens also with 3-byte values, e.g. unicode character
U+2019 (not latin-1).
Sending characters with ascii equivalents works.
I use Debian unstable, python 2.3, jabber.py 5.0. Locale
is iso-8859-15.
eekaikko@mail.student.oulu.fi
Logged In: NO
Try to specify your encoding in the xmlstream module.
Or do apt-get install python-xmpp ;)
Logged In: NO
This was a Python FAQ item after all. Sorry.
http://www.python.org/doc/faq/programming.html#what-does-unicodeerror-ascii-decoding-encoding-error-ordinal-not-in-range-128-mean
BTW, jabber.py has minimal dependencies, and it's LGPL
unlike xmppy. Therefore I'm sad jabber.py is dying.
If you want to see a new small project using jabber.py,
look at
http://iki.fi/eelik/jabberbiblebot/
The unicode problem is solved there using unicode()
function.