[PyKDE] QObject.trUtf8 doesn't accept unicode strings.
Rick van Hattem
Rick.van.Hattem at fawo.nl
Wed Jan 3 15:57:44 GMT 2007
On Wednesday 03 January 2007 16:30, Phil Thompson wrote:
> On Wednesday 03 January 2007 3:13 pm, Rick van Hattem wrote:
> > Hello everyone,
> > I was just writing some code today and after a while I came across some
> > code that used unicode strings, normally not a problem but I noticed that
> > tr and trUtf8 both don't accept unicode strings. Would it be possible to
> > add this since it would be logical to convert a python unicode string to
> > a QT escaped unicode string.
> > Example code:
> > from PyQt4 import QtCore
> > object = QtCore.QObject()
> > normal_string = str('test')
> > unicode_string = unicode('test')
> > ''' this works '''
> > object.tr(normal_string)
> > object.trUtf8(normal_string)
> > ''' this doesn't '''
> > object.tr(unicode_string)
> > object.trUtf8(unicode_string)
> > Naturally, the bottom two give a TypeError but I would expect it to do a
> > cast to str() for tr or just accept the string for trUtf8.
> tr() takes a char * and not a QString, so the PyQt version takes a string
> object and not a unicode object.
> PyKDE mailing list PyKDE at mats.imk.fraunhofer.de
I am aware of that, but I think it would be nice if trUtf8 would support it
(yes, it would have to be converted from unicode() to the escaped str()
version. It's kind of pointless to use unicode internally (when needed) and
not being able to use it because the tr functions don't support it.
I'm guessing QString doesn't support it either since QString normally takes a
char as argument.
Rick van Hattem Rick.van.Hattem(at)Fawo.nl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: not available
Url : http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20070103/7f83065f/attachment.bin
More information about the PyQt