[Development] Why we *have to* remove codecFor... ?

Loaden loaden at gmail.com
Sun Apr 22 12:59:55 CEST 2012


After test, I can sure this code can works well on Windows 32bit + MSVC2010
or Linux 64bit + GCC4.6.2 with Qt4.
But can't work with Qt5.
Please give me a sulution about this case.

>
> #include <QApplication>
> #include <QLabel>
> #include <QTextCodec>
> #include <QTextStream>
> #include <QDebug>
>
> int main(int argc, char *argv[])
> {
> #ifdef Q_WS_WIN
>     QTextCodec *codec = QTextCodec::codecForName("GBK");
> #else
>     QTextCodec *codec = QTextCodec::codecForName("UTF-8");
> #endif
>     QTextCodec::setCodecForLocale(codec);
> #if QT_VERSION < 0x050000
>     QTextCodec::setCodecForCStrings(codec);
>     QTextCodec::setCodecForTr(codec);
> #endif
>     QApplication app(argc, argv);
>     QString str = "Hello世界World!你好!";
>     QTextStream out(stdout);
>     qDebug() << "Hello世界World!你好!";
>     out << str << endl;
>     QLabel *label = new QLabel(str + QObject::tr("Hello世界World!你好!"));
>     label->show();
>     return app.exec();
> }
>



2012/4/22 Loaden <loaden at gmail.com>

>    (I don't have any clue about MSVC).
>>
> That the point! In current solution, It's does't work for this case if use
> MSVC Compiler.
> My Point:
> Please don't think about of MSVC users.
> Or, please give me a way to fix the problem.
>  2012/4/22 Giuseppe D'Angelo <dangelog at gmail.com>
>
>> You can do that -- as I said in my link, that requires that the
>> compiler emits UTF-8 as the execution charset for that literal. gcc
>> simply leaves the source bytes untrasformed if you don't pass the
>> various -fexec-charset options, so all it's required is that your
>> source code is encoded using UTF8-8. (I don't have any clue about
>> MSVC).
>>
>
>
>
> --
> Best Regards
> Yuchen
>
>


-- 
Best Regards
Yuchen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20120422/1443bed0/attachment.html>


More information about the Development mailing list