[Qt-interest] QString::toLower() issues with two-byte chars

Tibor Kiss tibor at wiesen.at
Fri Mar 12 08:14:51 CET 2010


Or you can try to do this in your main() before anything else:

QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));

Hope this helps.
Tibor

2010/3/12 Girish Ramakrishnan <girish at forwardbias.in>

> Øyvind Vågen Jægtnes wrote:
> > Hi,
> >
> > I have some problems using QString::toLower() on strings containing
> > norwegian chars.
> >
> > A simple test program:
> >
> > #include <QtDebug>
> >
> >
> > int main(int argc, char **argv)
> > {
> >     qDebug() << QString("æøå").toLower();
> >     return 0;
> > }
> >
>
> The QString(char *) constructor assumes that the c-style string is
> ASCII. The above code is equivalent to
> QString::fromAscii("æøå").toLower() which is not what you want.
>
> So, do QString::fromUtf8("æøå") and then you will get expected results.
>
> Girish
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100312/cf82ce3d/attachment.html 


More information about the Qt-interest-old mailing list