如何编译支持文本编解码器的 Qt 库 4.7.1?
我已经成功构建了静态Qt库,我可以看到plugins/codecs/libqcncodecs.a,但我仍然无法像这样使用GB18030:
QTextCodec::codecForName("GB18030")
而且我仍然找不到中文相关的编解码器,
foreach (int mib, QTextCodec::availableMibs()) {
QTextCodec *codec = QTextCodec::codecForMib(mib);
QString sortKey = codec->name().toUpper();
qDebug()<<sortKey;
}
这就是我的应用程序的输出:
"SYSTEM"
"UTF-8"
"ISO-8859-1"
"ISO-8859-15"
"UTF-32LE"
"UTF-32BE"
"UTF-32"
"UTF-16LE"
"UTF-16BE"
"UTF-16"
"MULELAO-1"
"ROMAN8"
"TIS-620"
"WINSAMI2"
"APPLE ROMAN"
"WINDOWS-1258"
"WINDOWS-1257"
"WINDOWS-1256"
"WINDOWS-1255"
"WINDOWS-1254"
"WINDOWS-1253"
"WINDOWS-1252"
"WINDOWS-1251"
"WINDOWS-1250"
"IBM866"
"IBM874"
"IBM850"
"ISO-8859-16"
"ISO-8859-14"
"ISO-8859-13"
"ISO-8859-10"
"ISO-8859-9"
"ISO-8859-8"
"ISO-8859-7"
"ISO-8859-6"
"ISO-8859-5"
"ISO-8859-4"
"ISO-8859-3"
"ISO-8859-2"
"KOI8-U"
"KOI8-R"
"ISCII-MLM"
"ISCII-KND"
"ISCII-TLG"
"ISCII-TML"
"ISCII-ORI"
"ISCII-GJR"
"ISCII-PNJ"
"ISCII-BNG"
"ISCII-DEV"
"TSCII"
如何添加中文文本编解码器?
I've successfully built static Qt library and I could see plugins/codecs/libqcncodecs.a, but I still can not use GB18030 like this:
QTextCodec::codecForName("GB18030")
and all I still couldn't find Chinese related codecs by
foreach (int mib, QTextCodec::availableMibs()) {
QTextCodec *codec = QTextCodec::codecForMib(mib);
QString sortKey = codec->name().toUpper();
qDebug()<<sortKey;
}
That's the output of my app:
"SYSTEM"
"UTF-8"
"ISO-8859-1"
"ISO-8859-15"
"UTF-32LE"
"UTF-32BE"
"UTF-32"
"UTF-16LE"
"UTF-16BE"
"UTF-16"
"MULELAO-1"
"ROMAN8"
"TIS-620"
"WINSAMI2"
"APPLE ROMAN"
"WINDOWS-1258"
"WINDOWS-1257"
"WINDOWS-1256"
"WINDOWS-1255"
"WINDOWS-1254"
"WINDOWS-1253"
"WINDOWS-1252"
"WINDOWS-1251"
"WINDOWS-1250"
"IBM866"
"IBM874"
"IBM850"
"ISO-8859-16"
"ISO-8859-14"
"ISO-8859-13"
"ISO-8859-10"
"ISO-8859-9"
"ISO-8859-8"
"ISO-8859-7"
"ISO-8859-6"
"ISO-8859-5"
"ISO-8859-4"
"ISO-8859-3"
"ISO-8859-2"
"KOI8-U"
"KOI8-R"
"ISCII-MLM"
"ISCII-KND"
"ISCII-TLG"
"ISCII-TML"
"ISCII-ORI"
"ISCII-GJR"
"ISCII-PNJ"
"ISCII-BNG"
"ISCII-DEV"
"TSCII"
How to add Chinese textcodecs?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
文档说:“要静态链接这些插件,您需要在您的应用程序中使用 Q_IMPORT_PLUGIN() 宏,并且您需要使用 QTPLUGIN 将所需的插件添加到您的构建中。”
我认为您的应用程序中缺少
Q_IMPORT_PLUGIN(qcncodecs)
。The documentation says: "To link statically against those plugins, you need to use the Q_IMPORT_PLUGIN() macro in your application and you need to add the required plugins to your build using QTPLUGIN."
I think you are missing a
Q_IMPORT_PLUGIN(qcncodecs)
in your application.