thisisparker / cursewords

:pencil: Terminal-based crossword puzzle solving interface
GNU Affero General Public License v3.0
249 stars 30 forks source link

Unicode/ASCII issue when drawing grid #12

Closed mnp closed 5 years ago

mnp commented 5 years ago

Python 3.6.7 in a gnome-terminal, installed with pip3 install --user. Thanks!

$ wget http://levien.com/Social%20rule.puz
$ cursewords 'Social rule.puz'

Traceback (most recent call last):
  File "/home/mnp/.local/bin/cursewords", line 11, in <module>
    sys.exit(main())
  File "/home/mnp/.local/lib/python3.6/site-packages/cursewords/cursewords.py", line 751, in main
    grid.draw()
  File "/home/mnp/.local/lib/python3.6/site-packages/cursewords/cursewords.py", line 150, in draw
    + self.term.dim(top_row))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 10-70: ordinal not in range(128)
mnp commented 5 years ago

Solved my own problem. Bit the bullet and...

export LANGUAGE="en_US.UTF-8"
export LANG="en_US.UTF-8"
thisisparker commented 5 years ago

OK, good to know! @mnp do you happen to know what your $LANG/$LANGUAGE were set to before? And if you didn't set them yourself, would you mind saying what your OS set-up is?

mnp commented 5 years ago

Refining the above: First, I was using LANG=C, that was no bueno. There was actually an OS bug long ago in the GNU-C library that would make sort about 10x slower because the UTF-8 collation function was used instead of the old K&R one. Anyway, there may be no reason to use LANG=C now. This was Ubuntu Bionic in a gnome-terminal.

Also, all it needed was export LANG=en_US.UTF-8. It seems $LANGUAGE was not necessary.

thisisparker commented 5 years ago

Alright, great. I'm closing this issue because we got it resolved for you (and it seems to be a pretty isolated case, at least so far) but I've opened #17 to provide a better failure notice on things like this, generally.