Nic0 / tyrs

Twitter and Identica client using curses
http://tyrs.nicosphere.net
61 stars 10 forks source link

UnicodeEncodeError when writing non-ASCII characters in a tweet #115

Closed ghost closed 12 years ago

ghost commented 12 years ago

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 <module>
    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.

Nic0 commented 12 years ago

Hi,

First of all congratulations for this project. Thank you!

Are you using the latest release, or the latest git? This should be related to this issue https://github.com/Nic0/tyrs/issues/112 Here the quick fixe: https://github.com/Nic0/tyrs/commit/95b76d8b80d67037b20ea3a52a85d69954ea1130

It was a problem with urwid 0.9.x -> 1.0.x I guess I haven't done any release since, but I should indeed.

Thanks for your feedback.

ghost commented 12 years ago

The latest git solved the problem, thanks for responding so quickly!