[Qt-interest] QString is changing when the first character is any special character.

Asheq Hamid asheq at ankur.org.bd
Mon Feb 22 11:59:36 CET 2010


Hi,

I am working as a developer for a localization editor using PyQt.

I have used QSyntaxhighlighter class. The HighlightBlock function is
receiving the associated textedit box's text content as its text parameter.
But when there is a special character like *,&,%,+ etc. as the first
character of the text parameter of highlightblock function the rest
non-ascii characters of the QString are changed. Why is this happening? How
can I get the unchanged actual value?

I tested it a bit more and found that this happens in other cases as well. I
tested with a short code :

#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
from PyQt4 import QtCore
text = QtCore.QString("%(devicename)s está sincronizado actualmente con
%(synclist)s.")
print text

The output was:
%(devicename)s está sincronizado actualmente con %(synclist)s.

So you can see that á is changed to  á. As I deleted the first % character,
I saw á is not changed anymore.

It will be really helpful if someone help me with a solution. How can I get
the actual value?

Thanking all,

-Asheq
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100222/6cd01623/attachment.html 


More information about the Qt-interest-old mailing list