Noam M Noam M - 3 months ago 13
Linux Question

QSqlQuery returns "???" for none English string

When running the code below the result is 'אבגדה' in Windows and '?????' on Linux, seems that
the

qry.value(0)
(a QVarient type) using a defult coding. In Linux I'm using free.dts and odbc.ini in the driver level

How to set QSqlQuery so that the return format will be UTF16?

What is the returned format?

QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
db.setDatabaseName("..."); //Some valid connection string

QByteArray ba;
char* _buffer11;

if(db.open())
{
QSqlQuery qry(db);
qry.prepare("Select UTF16 From DataTypes WHERE ID=9");

if(qry.exec())
{
//* Parse query results to DT format and write it to temp buffer.
QVariantList resultList;

while(qry.next())
{
resultList << qry.value(0);
}
}

// ...
}

Answer

I found the solution, the line client charset = UTF-8 should be added to the freetds.conf file

[SERVER_1]
host     = 192.168.192.44
instance = SQLEXPRESS   
tds version = 8.0
client charset = UTF-8