Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

printing sc2reader objects in python2 fails on unicode characters #159

Open
jon-n opened this issue Oct 20, 2013 · 3 comments
Open

printing sc2reader objects in python2 fails on unicode characters #159

jon-n opened this issue Oct 20, 2013 · 3 comments
Labels

Comments

@jon-n
Copy link

jon-n commented Oct 20, 2013

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

@GraylinKim
Copy link
Owner

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.

@GraylinKim
Copy link
Owner

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.

@jon-n
Copy link
Author

jon-n commented Nov 19, 2013

Okay, thanks for looking into it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants