1

I wrote a script in Python 2 which is separated in 4-5 modules. I use the Hungarian language in the script, which contains several unusual characters like öüóőúéáűí. I wrote the modules on Win7 with an original cp-1250 coding, and then I moved to Ubuntu raring, where the system default is Utf-8.

First Tkinter left the spec. letter containing labels blank, which I managed to debug by setting every coding in the beginning of the modules to # -*- Utf-8 -*-.

Entries started to go mad too. Their .get() methods raised UnicodeDecodeError: 'ascii' codec can't decode byte...

And finally if for example module a.py had a dictionary dict = {'Sándor': 16} and module b.py has a line a.dict['Sándor'], it raises KeyError, as if dict didn't contain 'Sándor'. It doesn't do this with strings containing only normal characters, not does this with dictionaries of the module's own.

1 Answer 1

3

I wrote a script in python2... I use the Hungarian language in the script...

Did you use unicode literals? No, you did not. Rewrite your script to use and handle them properly.

{u'Sándor': 16}

Unicode In Python, Completely Demystified

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.