Win-1251 codepage and QIBASE driver
-
-
WIN1251 do not work to(
are both not return error are both not working!http://hin.dp.ua/files/down/QIBASE_fig1.png(See picture)!
-
You should try "windows-1251" (the value for the connection parameter must be a valid codec for "QTextCodec":http://doc.qt.nokia.com/4.7/qtextcodec.html)
-
windows-1251 and Windows-1251 are do not work
In this case wrote that character set is not defined. See below"errors text":http://hin.dp.ua/files/down/QIBASE_fig2.png
-
According to "QIBASE Unicode Support and Text Encoding":http://doc.qt.nokia.com/4.7/sql-driver.html#qibase-unicode-support-and-text-encoding it falls back to Unicode when the encoding you request is not available (not availabel in QTextCodec, according to a quick look to the source code of the qsql_ibase plugin).
CP1251 and Windows-1251 are valid in QTextCodec but may not be correct for IBase; on the other hand WIN1251 and WIN-1251 may be correct for IBase but are not valid for QTextCodec. So this seems to be a loose-loose situation.
One solution might be to create your own QTextCodec according to the "API docs":http://doc.qt.nokia.com/4.7/qtextcodec.html#creating-your-own-codec-class. I'd leave all the functionality to a codec you get with codecForName(), saved as a class-private pointer to your new codec and delegate all methods to the respective methods of the worker codec (except the name/aliases of course).
Or you add another alias to src/corelib/codecs/qsimplecodec.cpp and compile your Qt libs manually (i.e. not use the precompiled ones).
-
You mean it?
in file src/corelib/codecs/qsimplecodec.cpp
@
...
{ "windows-1251", { "CP1251", "WIN1251", "WIN-1251", 0 }, 2251,
{ 0x0402, 0x0403, 0x201A, 0x0453, 0x201E, 0x2026, 0x2020, 0x2021,
0x20AC, 0x2030, 0x0409, 0x2039, 0x040A, 0x040C, 0x040B, 0x040F,
...
@And in this case, along with my program I will must to distribute own, modified library? Isn't it?
-
Did the above qsimplecodec.cpp change fix your problem?
-
Seems to be reported as bug "QTBUG-15608":http://bugreports.qt.nokia.com/browse/QTBUG-15608
-
in the file C:\Qt\Qt5.7.0\5.7\Src\qtbase\src\sql\drivers\ibase\qsql_ibase.cpp
find the code:
// Use UNICODE_FSS when no ISC_DPB_LC_CTYPE is provided
if (encString.isEmpty())
encString = QLatin1String("UNICODE_FSS");
else {
d->tc = QTextCodec::codecForName(encString.toLocal8Bit());
if (!d->tc) {
qWarning("Unsupported encoding: %s. Using UNICODE_FFS for ISC_DPB_LC_CTYPE.", encString.toLocal8Bit().constData());
encString = QLatin1String("UNICODE_FSS"); // Fallback to UNICODE_FSS
}
}
to redo:
// Use UNICODE_FSS when no ISC_DPB_LC_CTYPE is provided
if (encString.isEmpty())
encString = QLatin1String("UNICODE_FSS");
else
{
QString temp = QLatin1String("WIN1251");
if(encString == temp)
{
qDebug()<<"win1251 detected";
temp = QLatin1String("windows-1251");
d->tc = QTextCodec::codecForName(temp.toLocal8Bit());
}
else
{
d->tc = QTextCodec::codecForName(encString.toLocal8Bit());
if (!d->tc)
{
qWarning("Unsupported encoding: %s. Using UNICODE_FFS for ISC_DPB_LC_CTYPE.", encString.toLocal8Bit().constData());
encString = QLatin1String("UNICODE_FSS"); // Fallback to UNICODE_FSS
}
}
}compile your driver as shown in the documentation:
cd $QTDIR/qtbase/src/plugins/sqldrivers/ibase
qmake "INCLUDEPATH+=/opt/interbase/include" "LIBS+=-L/opt/interbase/lib" ibase.pro
make
move dll from C:\Qt\Qt5.7.0\5.7\Src\qtbase\plugins\sqldrivers to C:\Qt\Qt5.7.0\5.7\mingw53_32\plugins\sqldrivers
enjoy it