Hello Everyone

I have another mysql UTF-8 problem, I have a table that has some records stored in it in UTF-8 format (some records are in English, and some of them are Arabic)

my problem is that if I use php to retried the entries, they are encoded correctly and I can see both the Arabic and the English words. but I also need to use Qt to read the same entries and display them in a Qt table.

The entry in the database looks like this in UTF-8 encoding (in php)
دبي

I'm doing it and I'm getting these values.
??دب

the above line, has partially correct value, it gets 2 out of 3 characters correct, but I have NO idea why its NOT showing this correctly.

Below is my code, and I would appreciate any suggestion you have.


Qt Code:
  1. bool ret = query.exec("select name_searchword from searchword where id_company = 1125");
  2. while(query.next())
  3. {
  4. QByteArray ba = query.value(0).toByteArray();
  5. QString st = QString::fromUtf8( ba.data() );
  6. qDebug() << "Str is :" << st;
  7. }
To copy to clipboard, switch view to plain text mode 

The output is:

Str is : دب??


I've tried to use QTextCodec::setCodecForCStrings and set the value to UTF-8, but thats ONLY made it worse.

I've also tried those 2 lines, together and one on its own, and still no results.

Qt Code:
  1. QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8") );
To copy to clipboard, switch view to plain text mode 
Qt Code:
  1. QTextCodec *codec = QTextCodec::codecForName("UTF8");
To copy to clipboard, switch view to plain text mode 

Thanks a lot for your help