Closed kaosengr closed 5 years ago
Changed the print statement on line 70 to
print("\<!-- Decoding symbol " + str(c) + ": \\"" + symbol + "\\" -->")
doesn't print the symbol being converted in the svg comments but not really needed.
More could be removed - ": ""
For reference, the error is in: https://github.com/JayFoxRox/xbox-tools/blob/d060d2f3040c5e05b66d3ac18bb072acd8a0ff7a/xtf-converter/main.py#L70
The problem is that @kaosengr is using the Windows CMD prompt, which is an ASCII terminal. Here's how I reproduced it:
$ python2 -c "print(u'\xa0')"
$ PYTHONIOENCODING=ascii python2 -c "print(u'\xa0')"
Traceback (most recent call last):
File "<string>", line 1, in <module>
UnicodeEncodeError: 'ascii' codec can't encode character u'\xa0' in position 0: ordinal not in range(128)
$ PYTHONIOENCODING=ascii python3 -c "print(u'\xa0')"
Traceback (most recent call last):
File "<string>", line 1, in <module>
UnicodeEncodeError: 'ascii' codec can't encode character '\xa0' in position 0: ordinal not in range(128)
The backslash-removal simply broke printing of symbol
, hence you worked around the crash by accident. A better workaround is to remove that line altogether.
However, to fix this problem for everyone, we should add an error handler for this line, which catches the error and simply doesn't print the symbol part (symbol
) of the message, if the terminal can't print it.
I don't think I'll fix it myself - you found your workaround anyway (which is easy enough) and it's a rare issue (most terminals will be some form of unicode).
This issue remains open until the problem is fixed in the code.
Closed, because project moved to https://github.com/XboxDev/xtf-converter
An equivalent issue has been created on the new upstream.
G:\github.com\JayFoxRox\xbox-tools\xtf-converter>.\main.py "Xbox.xtf" >"Xbox.svg" Traceback (most recent call last): File "G:\github.com\JayFoxRox\xbox-tools\xtf-converter\main.py", line 70, in
print("\<!-- Decoding symbol " + str(c) + ": "\\" + symbol + "\\" -->")
UnicodeEncodeError: 'ascii' codec can't encode character u'\xa0' in position 27: ordinal not in range(128)
Update 1: Text left out of the message for the print function between the quotes;
Update 2 and 3: Ah ha, figured out how to get the comment to show. Escape (\) the comment tag characters.
\<!-- Decoding symbol " + str(c) + ": \\"" + symbol + "\\" -->
Update 3: Using Pyhon 2.7.13
Update 4: The backslashes are actually still in the print("... just they get stripped out when posting without escaping them too. Fixed now to show they are still in the print function.