[Qt-interest] QString and Unicode literals
Jochen Roemmler
jochen444 at concept.de
Fri May 29 14:53:33 CEST 2009
> int main(int argc, char* argv[])
> {
> QCoreApplication app(argc, argv);
> QTextCodec* codec = QTextCodec::codecForName("UTF-8");
> if (!codec) return 1;
> QString str = QString::fromUtf8("Test \u20AC");
> qDebug() << str;
> return 0;
> }
...well it really boils down to that:
QString str = QString::fromUtf8("Test \u20AC");
I was experimenting with the default codec for C strings, like so:
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
QString str("Test \u20AC");
...which also worked for me.
-Jochen
More information about the Qt-interest-old
mailing list