printing sc2reader objects in python2 fails on unicode characters
I have a replay where a player has a special character "ó" in his name. When I try to load the replay and call replay.players, it throws an ascii error:
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/sc2reader/objects.py", line 313, in __repr__
return str(self)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xf3' in position 14: ordinal not in range(128)
On line 313 in objects.py like it mentions, I think this is caused by the str(self) that defaults to the default ASCII encoding.
put a sample replay here with a script: https://github.com/athst/sc2rep-example1
This is a Python 2/3 problem in handling unicode strings. I'll try to fix it but until then you can create your own string formatting methods for sc2reader objects following python2 conventions.
I can't figure out how to make this formatting work in both Python 2 and 3. I don't want to have two versions of every print routine but I don't see another way to do it. I'm going to keep looking but in the meantime anyone affected by this should either upgrade to Python3 (which works) or do the print formatting themselves.
Okay, thanks for looking into it.