[PyKDE] QObject.trUtf8 doesn't accept unicode strings.
Tomasz Melcer
liori at exroot.org
Wed Jan 3 18:37:33 GMT 2007
Giovanni Bajo napisał(a):
> Your source code should look like this:
>
> self.trUtf8("foo bar translate this")
>
> Notice that the return value of tr()/trUtf8() is obviously a QString
> (duck-typable and convertible to Python's unicode), so your application will
> still be fully unicode. It's only the literal in the source code
> (*immediatly* surrounded by the tr() call) which is a 8-byte str.
>
> BTW: since all my sources are UTF-8, I prefer to specify it as default
> encoding for tr (QTextCodec.setCodecForTr) so that I can later use the
> shorter tr() everywhere in the code.
Just curious: what happens if I want a string to translate which
contains any special unicode symbols, like math operators? I couldn't
express them as 8-byte characters...
Tomasz Melcer
More information about the PyQt
mailing list