PDA

View Full Version : Qt5 + qdbf encoding problem



folibis
3rd September 2013, 14:28
In my program I use qdbf lib to read data from dbf files.
The dbf files contains data encoded with UTF-8
So when I run simple test program from http://code.google.com/p/qdbf/ I get my data as abracadabra, like this - "Таланд жа"
The dbf file in UTF-8, the source cpp file in UTF-8 so I don't understand what I do wrong.

Windows 7 x32, MinGW 4.8, Qt 5.1, QtCreator 2.7.2

wysota
3rd September 2013, 22:02
The test program is written for Qt4. Qt5 may have a slightly changed string handling thus relying on this example is probably not the best idea.

The string you get is totally screwed up (even length-wise) so it won't help much with detecting the problem. Basically when you have utf-8 data, you should tell QString that the data is utf-8 by using QString::fromUtf8() rather than blindly hoping Qt converts your text by itself.