Kirill Titov
Kirill Titov

Reputation: 2109

Encoding problems in PyQt

My program stores file index in file packed by cPickle. There are non-english filenames. When I just do this

print f [0]

where f [0] is "\xc2\xe8\xf1\xee\xea\xee\xf1\xed\xfb\xe9 \xe3\xee\xe4" ("Високосный год" in normal view), it prints the string in proper way — in russian.

When the program manually adds the string u'Високосный год' to QTreeView, everything is fine.

But when the program puts this string ("\xe3\xee\xe4" etc.) straight from unpickled file to QTreeView, it becomes like that:

alt text http://img170.imageshack.us/img170/9226/encoding.png

Is there any way to solve that?

Upvotes: 0

Views: 991

Answers (1)

Vinay Sajip
Vinay Sajip

Reputation: 99490

Have you run decode on the unpickled string using the correct encoding ("cp1251" by the look of it)? If not, you need to do this to make sure you're passing a Unicode string to the GUI.

Upvotes: 2

Related Questions