Frage

  • OS: Windows 8.1
  • MS SQL Server 2008 R2
  • Qt 5.2
  • DB Driver "QODBC"

I have a little problem with the umlaut.

I create the table with a column NVARCHAR(35) and fill the table with N’1ö2’. When I select something from the SQL Management Studio I see the umlaut ö.

In Qt I use e.g. this qDebug() << “name“ << aQuery->value(„name“).toString(); but I get name "1?2"

Even when I loop the available codecs (QTextCodec::availableCodecs();) I don’t get a valid 1ö2 string.

QByteArray ba = aQuery->value(„name").toByteArray();
qDebug() << "hex" << ba.toHex() << "str" << QString(ba) << "count" << ba.count();

Output:

hex "31efbfbd32" str "1?2" count 5

31 is 1
32 is 2
efbfbd is unicode for ? (REPLACEMENT CHARACTER)

So my question is pretty simple - what I’m doing wrong? ;-)

Thanks, Matthias

War es hilfreich?

Lösung

Okay it works now. A single aQuery.clear; before I do the request did it. ;-)

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top