On 6 July 2011 14:58, Ian Ward <[email protected]> wrote:
> Patrick Totzke wrote on 2011-07-06 07:40:
>> wow: i seem to get a lot of encoding errors with the development
>> version.. for instance this one here.
>>
>>     urwid.AttrMap.__init__(self, urwid.Text(bodytxt), 'message_body')
>>   File 
>> "/usr/local/lib/python2.7/dist-packages/urwid-0.9.10_pre-py2.7-linux-i686.egg/urwid/widget.py",
>> line 467, in __init__
>>     self.set_text(markup)
>>   File 
>> "/usr/local/lib/python2.7/dist-packages/urwid-0.9.10_pre-py2.7-linux-i686.egg/urwid/widget.py",
>> line 509, in set_text
>>     self._text, self._attrib = decompose_tagmarkup(markup)
>>   File 
>> "/usr/local/lib/python2.7/dist-packages/urwid-0.9.10_pre-py2.7-linux-i686.egg/urwid/util.py",
>> line 375, in decompose_tagmarkup
>>     text = u"".join(tl)
>> UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position
>> 186: ordinal not in range(128
>>
>> i am sure that "bodytxt" is valit utf8, because i explicitly encoded
>> it as such. how come there is encoding going on anyway?
>
> Yes, that looks like a bug.  Urwid is supposed to accept either encoded
> text or unicode objects for output.  The code for handling that *and*
> dealing with unicode changes in Python 3 is quite difficult to get right.
>
> However, why are you encoding your text to UTF-8?  Do you intend your
> application to only be used by people with that UTF-8 enabled, or are
> you detecting the system's encoding yourself?

I have strings in various encodings to dislpay and thought it was a good idea to
first force them all to utf8.
Now I realized that just converting them to unicode with
>unicode(mystring, whateverenc, errors='replace')
does the job. I can then just give this to the widget as you say.

_______________________________________________
Urwid mailing list
[email protected]
http://lists.excess.org/mailman/listinfo/urwid

Reply via email to