Results 1 to 3 of 3

Thread: Sqlite and UTF8 data

  1. #1
    Join Date
    Jan 2006
    Posts
    75
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Sqlite and UTF8 data

    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:

    Qt Code:
    1. QString s = "SELECT * FROM edict_words WHERE reading = :reading ";
    2. q.prepare(s);
    3. q.bindValue(0, value);
    4. q.exec();
    To copy to clipboard, switch view to plain text mode 

    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?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Sqlite and UTF8 data

    What does bindValue() return? What does prepare() return? What's the data type of "value"?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jan 2006
    Posts
    75
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Sqlite and UTF8 data

    Wysota,

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

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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.