Results 1 to 4 of 4

Thread: Insert unicode in SQlite

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2008
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Insert unicode in SQlite

    Thanks for the answer.

    I'm not sure it will work, because I tried to fill my SQLite data file with an other gui program then i tried to show the caracter with my model/view from and it work.

    I think the problem occure with the "insert into" Qt . However, i'm absolutely not certain, it's why i'm asking !

  2. #2
    Join Date
    Jul 2010
    Location
    Fortaleza, Brazil
    Posts
    4
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Insert unicode in SQlite

    1- Exec this before QApplication instantiation (or declaration)
    QTextCodec::setCodecForCStrings(QTextCodec::codecF orName("UTF-8"));
    QTextCodec::setCodecForTr(QTextCodec::codecForName ("UTF-8"));
    QTextCodec::setCodecForLocale(QTextCodec::codecFor Name("UTF-8"));

    2- Certify your cpp file are UTF-8 encoded
    3- Try to change your code:
    query.exec("insert into kanji values(0, '<all>', '0')");
    query.exec("insert into kanji values(1, 'æ—¥', 'Soleil')");
    query.exec("insert into kanji values(2, '火', 'Feu')");
    query.exec("insert into kanji values(3, 'æ°´', 'Eau')");

    to:
    query.prepare("insert into kanji values(:id, :kanji, :desc)");
    query.bind(1, 0); query.bind(2, '<all>'); query.bind(3, '0'); query.exec();
    query.bind(1, 1); query.bind(2, 'æ—¥'); query.bind(3, 'Soleil'); query.exec();
    query.bind(1, 2); query.bind(2, '火'); query.bind(3, 'Feu'); query.exec();
    query.bind(1, 3); query.bind(2, 'æ°´'); query.bind(3, 'Eau'); query.exec();

    Try this and tell me the result.

    If you use linux you can use sqliteman, or on windows SqliteExpert Personal Edition to open the database.

Similar Threads

  1. Bulk insert into SQLite
    By munna in forum Qt Programming
    Replies: 6
    Last Post: 19th November 2007, 03:56

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
  •  
Qt is a trademark of The Qt Company.