[PyQt] Using Unicode

Raoul Snyman raoul.snyman at saturnlaboratories.co.za
Wed Jun 17 08:38:36 BST 2009

Hi Gabriel,

On Wed, 17 Jun 2009 09:13:21 +0200, Gabriel Hahmann wrote:
> QtGui.QPushButton(self.tr('&Next >'))
> In fact this is some excerpt of parts of the code. What I want to do
> is translate every word of the text to Portuguese. I tried simply
> translating but then it gives me an error of outside ASCII range.
> Then I added coding: utf-8 at the top of the file. Changed self.tr to
> self.trUtf8 with no luck. I tried self.tr(unicode("Some text")) with
> no luck too.
> The Portuguese characters have é, ç, ê, ô, etc. I tried with
> self.trUtf8 and putting the code in hex like this self.trUtf8("\00C9")
> without success. I've read a lot of pages telling how to print unicode
> characters but I couldnt print a single character right now.

Unfortunately I am English, so I haven't run into these problems myself,
but a project I'm working on at the moment is having similar problems with
one of our German testers. One thing I did notice in your code is that you
are not sending Unicode strings through. Try using the u'Some Text' (note
the "u") and see if that helps?

Let us know if this has any effect.

Raoul Snyman, B.Tech IT (Software Engineering)
Saturn Laboratories
e: raoul.snyman at saturnlaboratories.co.za
w: http://www.saturnlaboratories.co.za/
b: http://blog.saturnlaboratories.co.za/

More information about the PyQt mailing list