PDA

View Full Version : Sqlite and UTF8 data



kroenecker
28th March 2009, 16:59
I am working with a sqlite table with Japanese characters. The data appears to be just fine because I can use the sqlite command line utility to select entries and I can write QSqlQuery statements that pull data using the row id. However, when I try to construct queries that use Japanese characters to get data, nothing is returned.

For instance if I use the code below and value = わたし nothing is returned:



QString s = "SELECT * FROM edict_words WHERE reading = :reading ";
q.prepare(s);
q.bindValue(0, value);
q.exec();


I can replace "reading" with id and the bindValue "value" with a legitimate id number and my tableview will be populated with a nice row of data, showing proper Japanese characters. Otherwise, I can't seem to get anything from the table.

Any ideas?

wysota
28th March 2009, 22:58
What does bindValue() return? What does prepare() return? What's the data type of "value"?

kroenecker
19th April 2009, 14:49
Wysota,

Thanks for you suggestions. It turned out that I needed to wrap my search values like so:

QString value = QString::fromUtf8("わたし");