1

I'm translating a Ren'Py game, which involves redefining a function that converts numbers to written-out words in a particular language. Those strings are then handled and inserted into the game text by the main code of the game (which I can't modify).

My problem is that when I return strings that contain non-ascii characters like ö or ü, the game throws an exception when it gets to that point.

UnicodeDecodeError: 'utf8' codec can't decode bytes in position 2-4: unexpected end of data

Using character codes like \uC3B6 throws no exception, but I end up with a placeholder box instead of the character I want.

Is there any way to make the function return these characters properly without having access to the remaining code?

Andii
  • 337
  • 1
  • 5
  • 19
  • Always post the **full** traceback. What version of python are you using? Are you passing unicode strings or bytes strings? What is the output of `print(repr(mystring))`? – ekhumoro Oct 11 '16 at 16:20
  • Sorry, I should have mentioned I have very little experience with Python (I didn't even know about there being different string types)... and while trying to figure all this out, I just managed to find a solution myself.^^' – Andii Oct 11 '16 at 19:58

1 Answers1

0

Turns out I was using the wrong escape character and the wrong hex codes. And I had to use unicode strings. u'\xF6' and u'\xFC' work perfectly fine for the two characters I was trying to get.

Andii
  • 337
  • 1
  • 5
  • 19