⚠️ Forum Maintenance: Feb 6th, 8am - 14pm (UTC+2)
QSqlQuery and Umlauts
German Umlauts are not being displayed properly when querying my oracle database. Database's characterset is set to 'WE8MSWIN1252'...
I did not manage to find acceptable solutions on the forums...
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.
Yes, I am using QSqlQuery. Your solution did not work...
I was guessing that WE8MSWIN1252 is Windows-1252. You can choose other codecs from this list:
If 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 :(
Still need help with this :(
I lost overview what the status of the issue is. One driver delivers correct results the other doesn't, is it like this? Then it is a obviously a driver issue. Maybe you want to start a new thread where you present the results of your research so far.