0

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())
    {
        QVariantList resultList;

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

    // ...
}
Noam M
  • 3,156
  • 5
  • 26
  • 41

1 Answers1

0

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
Noam M
  • 3,156
  • 5
  • 26
  • 41