ihabunek / toot

toot - Mastodon CLI & TUI
GNU General Public License v3.0
1.16k stars 112 forks source link

Support non-Unicode locales #223

Open NoraCodes opened 2 years ago

NoraCodes commented 2 years ago

Hi! I am currently trying to run Toot on my Digital Equipment Corporation VT420, which doesn't support Unicode. The best I've got is ISO Latin-1. However, toot currently doesn't work at all in this locale:

nora@racketmousse:~$ LC_ALL=en_US.iso88591 toot tui
Traceback (most recent call last):
  File "/usr/bin/toot", line 11, in <module>
    load_entry_point('toot==0.27.0', 'console_scripts', 'toot')()
  File "/usr/lib/python3/dist-packages/toot/console.py", line 550, in main
    run_command(app, user, command_name, args)
  File "/usr/lib/python3/dist-packages/toot/console.py", line 532, in run_command
    return fn(app, user, parsed_args)
  File "/usr/lib/python3/dist-packages/toot/commands.py", line 338, in tui
    TUI.create(app, user).run()
  File "/usr/lib/python3/dist-packages/toot/tui/app.py", line 116, in run
    self.loop.run()
  File "/usr/lib/python3/dist-packages/urwid/main_loop.py", line 287, in run
    self._run()
  File "/usr/lib/python3/dist-packages/urwid/main_loop.py", line 385, in _run
    self.event_loop.run()
  File "/usr/lib/python3/dist-packages/urwid/main_loop.py", line 1494, in run
    reraise(*exc_info)
  File "/usr/lib/python3/dist-packages/urwid/compat.py", line 58, in reraise
    raise value
  File "/usr/lib/python3.9/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/lib/python3/dist-packages/urwid/main_loop.py", line 1454, in faux_idle_callback
    callback()
  File "/usr/lib/python3/dist-packages/urwid/main_loop.py", line 574, in entering_idle
    self.draw_screen()
  File "/usr/lib/python3/dist-packages/urwid/main_loop.py", line 589, in draw_screen
    self.screen.draw_screen(self.screen_size, canvas)
  File "/usr/lib/python3/dist-packages/urwid/raw_display.py", line 868, in draw_screen
    self.write(l)
  File "/usr/lib/python3/dist-packages/urwid/raw_display.py", line 286, in write
    self._term_output_file.write(data)
UnicodeEncodeError: 'latin-1' codec can't encode characters in position 0-4: ordinal not in range(256)

Similar errors occur with toot timeline. Would it be possible to get at least basic functionality without fancy Unicode characters?

Thanks!

P.S. here's what happens if you feed the Unicode characters into the VT. It's not particularly lovely. 2945d25be2b85f6e

kianryan commented 1 year ago

Not bad - further than I got while attempting login UnicodeEncodeError: 'latin-1' codec can't encode character '\u2713' in position 5: ordinal not in range(256) :-)

ihabunek commented 1 year ago

@NoraCodes Firstly, I love your use case. :) Currently the whole project assumes utf-8. Making it support latin1 would be possible, but might require some re-jigging. Probably won't be high on my list of priorities for the near future, sorry.