snakefire icon indicating copy to clipboard operation
snakefire copied to clipboard

UnicodeEncodeError in mainframe.py for non-ascii characters

Open bf4 opened this issue 14 years ago • 9 comments

e.g. from the log

self.statusBar().showMessage(self._("Joining room {room}...").format(room=room["name"])) UnicodeEncodeError: 'ascii' codec can't encode character u'\xeb' in position 1: ordinal not in range(128)

this results in not being able to perform most actions in the room. It does display the room name properly in the select box, so I'm not sure what's different about these methods. In any case, the room is not currently useable. I tried adding .encode("ascii", "ignore") in various places as a hack but didn't find them all.

bf4 avatar Nov 09 '11 07:11 bf4

Could you give me the gave of the failing room so I can replicate?

mariano avatar Nov 09 '11 12:11 mariano

Nërd Lounge™

bf4 avatar Nov 09 '11 13:11 bf4

Weird, I created a room with that exact name, and I'm able to join it correctly. There is an issue with the status bar (I don't see the warning you see, but the room name is not properly shown when displaying the Joining room message). I'm fixing that issue

mariano avatar Nov 09 '11 14:11 mariano

Try with the recent update (you have to pull from the GIT repo, since I haven't yet released packages for this)

mariano avatar Nov 09 '11 14:11 mariano

Will do tonight. thanks

bf4 avatar Nov 09 '11 18:11 bf4

hmm, that didn't appear to fix it... $HOME/.pythonbrew/pythons/Python-2.7.2/lib/python2.7/site-packages/snakefire-1.0.4-py2.7.egg/snakefire/mainframe.py", line 335, in joinRoom self.statusBar().showMessage(unicode(self._("Joining room {room}...").format(room=room["name"]))) UnicodeEncodeError: 'ascii' codec can't encode character u'\xeb' in position 1: ordinal not in range(128)

bf4 avatar Nov 11 '11 15:11 bf4

(I'm on OSX snowleopard FWIW)

bf4 avatar Nov 11 '11 15:11 bf4

It looks like something to do with how .format is called and what the interpolation expects. I don't really know python, but from reading it about it, it appears the django module smart_str https://code.djangoproject.com/browser/django/tags/releases/1.1.1/django/utils/encoding.py#L95 would help or maybe adding !r to the interpolated string, or see http://docs.python.org/tutorial/introduction.html e.g. u'Hello\u0020World !' u'Hello World !'

bf4 avatar Nov 11 '11 16:11 bf4

A related fix in #67 may have solved this. Could you test with latest git version? Thanks

mariano avatar May 20 '13 11:05 mariano