Olivia5k / doge

wow very terminal doge
https://pypi.python.org/pypi/doge/
MIT License
961 stars 91 forks source link

Outputs UTF-8 characters on LATIN1 terminals #55

Closed h3xx closed 8 years ago

h3xx commented 8 years ago

Script does not do appropriate checking of terminal LC_CTYPE locale to test whether the terminal can accept UTF-8 characters. This results in corrupt output.

Suggestion: Transform strings into acceptable character set before outputting.

Steps to reproduce:

$ LANG=en_US LC_CTYPE=en_US rxvt -e bash -c 'doge;read'

OR

$ LANG=en_US LC_CTYPE=en_US xterm -e bash -c 'doge;read'

Results in:

xterm

Olivia5k commented 8 years ago

Haha, that looks fun.

However, there is already some code handling non-UTF-8 cases. I am not sure why this isn't triggering for you, but it sure is for me when I run the snippets you specified.

Have you encountered this problem on a real-life machine or were you just mucking around with running non-UTF-8 stuff?

Cheers for finding inconsistent behavior anyway!

h3xx commented 8 years ago

Have you encountered this problem on a real-life machine or were you just mucking around with running non-UTF-8 stuff?

I ran it on the system and terminal I always use, using the configuration I use for pretty much all my computing.

The Python version I ran it under is 2.7.11. I know Python 2 has different string encoding handling than Python 3, so that may be the cause of it.