Nic0/tyrs — Issue #115: UnicodeEncodeError when writing non-ASCII characters in a tweet
Author: alejandrogomez
Created: 2012-01-07 11:49:45+00:00
State: open

First of all congratulations for this project.

Maybe I'm missing something here because the ```README``` file claims that it has UTF-8 support but I get the following error and traceback when trying to write non-ASCII characters in a tweet (e.g, í, á, é).

```
Traceback (most recent call last):
File "/usr/bin/tyrs", line 16, in
main()
File "/usr/lib/python2.7/site-packages/tyrs/tyrs.py", line 66, in main
init_tyrs()
File "/usr/lib/python2.7/site-packages/tyrs/tyrs.py", line 71, in init_tyrs
init_interface()
File "/usr/lib/python2.7/site-packages/tyrs/tyrs.py", line 88, in init_interface
user_interface = Interface()
File "/usr/lib/python2.7/site-packages/tyrs/interface.py", line 49, in __init__
self.main_loop()
File "/usr/lib/python2.7/site-packages/tyrs/interface.py", line 62, in main_loop
self.loop.run()
File "/usr/lib/python2.7/site-packages/urwid/main_loop.py", line 274, in run
self.screen.run_wrapper(self._run)
File "/usr/lib/python2.7/site-packages/urwid/raw_display.py", line 237, in run_wrapper
return fn()
File "/usr/lib/python2.7/site-packages/urwid/main_loop.py", line 307, in _run
self.event_loop.run()
File "/usr/lib/python2.7/site-packages/urwid/main_loop.py", line 682, in run
self._loop()
File "/usr/lib/python2.7/site-packages/urwid/main_loop.py", line 720, in _loop
self._watch_files[fd]()
File "/usr/lib/python2.7/site-packages/urwid/main_loop.py", line 358, in _update
self.process_input(keys)
File "/usr/lib/python2.7/site-packages/urwid/main_loop.py", line 447, in process_input
k = self._topmost_widget.keypress(self.screen_size, k)
File "/usr/lib/python2.7/site-packages/urwid/container.py", line 629, in keypress
return self.footer.keypress((maxcol,),key)
File "/usr/lib/python2.7/site-packages/urwid/container.py", line 1390, in keypress
key = w.keypress( (mc,)+size[1:], key )
File "/usr/lib/python2.7/site-packages/tyrs/editor.py", line 73, in keypress
urwid.Edit.keypress(self, size, key)
File "/usr/lib/python2.7/site-packages/urwid/widget.py", line 1036, in keypress
self.insert_text( key )
File "/usr/lib/python2.7/site-packages/urwid/widget.py", line 972, in insert_text
text = self._normalize_to_caption(text)
File "/usr/lib/python2.7/site-packages/urwid/widget.py", line 988, in _normalize_to_caption
return text.encode('ascii') # follow python2's implicit conversion
UnicodeEncodeError: 'ascii' codec can't encode character u'\xf1' in position 0: ordinal not in range(128)
```

It seems to be an issue with ```urwid```.