QSqlQuery and Umlauts
-
Are you using QSqlQuery? Then youre code will have a line like this:
@QString country = query.value(fieldNo).toString();@You must not accept the standard conversion here. Therefore try to change it to
@QByteArray byteArray = query.value(fieldNo).toByteArray();
QTextCodec *codec = QTextCodec::codecForName("Windows-1252");
QString string = codec->toUnicode(byteArray);
@I did not test the code.
-
I was guessing that WE8MSWIN1252 is Windows-1252. You can choose other codecs from this list:
http://doc.qt.nokia.com/4.7/qtextcodec.htmlIf none of the codecs matches your character set you can produce your own.
Did you already verify that the content in the database really has the format you expect? Try to dump the QByteArray in hex format to verify the encoding. -
Just found out that I got no problem when using the QOCI driver instead of QODBC, but I don't want to use this one since it is way slower than QODBC.
In the API I found:
For the Oracle 9 ODBC driver (Windows), it is neccessary to check "SQL_WCHAR support" in the ODBC driver manager otherwise Oracle will convert all Unicode strings to local 8-bit.I turned on "Force SQL_WCHAR support" on all of my data sources and now it is working! Thread can be closed...
edit: Oups, I was mistaken, just forget to set QOCI back to QODBC :(
-