Using native c++ driver (but not QT based) is my backup solution. At the moment I try to find QT5 based solution without need to recompile QT...
Zdenko On Tue, Aug 26, 2014 at 3:32 PM, Edgar Moraes Diniz < edgar.di...@openmailbox.org> wrote: > Hi, > > I had this problem here in Brazil, too, but with Qt 5.0, perhaps that's > the same point. > > To overcome this problem, I found two solutions: > > 1 (easier): Do you really have to use ODBC? Native drivers are supposedly > better and faster. Try using the native driver for your DB. > > 2 (not so easy): Go to the QODBC source file and replace every ocurrence > of: > > QString::fromUtf8 -> QString::fromLocal8Bit > QString::toUtf8 -> QString::toLocal8Bit > > > > I believe the sources are located in $QT_SRC/qtbase/src/sql/drivers/odbc/ > > At least, that solved my problem, before I switched to native driver (QOCI > - no problems with it). > > Hope it works. Best, > Edgar. > > Em 26/08/2014 10:14, zdenko podobny escreveu: > > Hello, > This is a secure message chain, protected by Virtru. > I try to retrieve strings from db with QODBC (QT 5.3.1 windows). > Database locale is en_US.819 (and ODBC driver does not work if client > locale is not set to en_US.819). Strings (stored by windows application in > db) are cp1250 encoded. > > And instead of "doručené" I got "doru?en?". > > Here is part of my code: > > QTextCodec::setCodecForLocale(QTextCodec::codecForName("cp1250")); > > QTextCodec *codec_db = QTextCodec::codecForName("latin1"); > > QSqlRecord rec = query.record(); > > qDebug() << "test: " << "doručené"; > > while (query.next()) { > > for (int x = 0; x < rec.count(); x++) { > > QVariant variant = query.value(x); > > if (rec.value(x).type() == QMetaType::QString) { > > QByteArray encodedString = > codec_db->fromUnicode(variant.toByteArray()); > > qDebug() << "db_str: " << encodedString; > > } > > } > > } > > How can I fix encoding of db output? > > PS: In python 3.4.1 I am able to get correct output (via pyodbc) with this: > > print("db_str:", db_str.encode('latin1').decode('cp1250')) > > But I would prefer to use C++ and QT5... > > Zdenko > > _______________________________________________ > Interest mailing > listInterest@qt-project.orghttp://lists.qt-project.org/mailman/listinfo/interest > > > -- > > /** > * @*author* Edgar Moraes Diniz > * > * edgar.di...@openmailbox.org > */ > > _______________________________________________ > Interest mailing list > Interest@qt-project.org > http://lists.qt-project.org/mailman/listinfo/interest > >
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest