Results 1 to 12 of 12

Thread: Reading umlaut letters from sqlite database

  1. #1
    Join Date
    Nov 2006
    Posts
    72
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Reading umlaut letters from sqlite database

    Hi!

    I am trying to read some German names from my sqlite database, and I have problems getting exact umlaut letters (Qt cuts of some bits wiht umlaut). This is my piece of code, where I am executing query:

    QString sStatement = "SELECT rp.id, rp.FirstName, rp.LastName, rp.Alias, rp.eMail, rp.Phone, "
    "rp.division, rp.comment "
    "FROM tbl_Responsible rp "
    "WHERE id = "
    "("
    "SELECT responsible_id FROM rel_TestCase_has_Responsible "
    "WHERE testcase_id = :currentTcId"
    ") "
    "ORDER BY rp.LastName ASC";

    m_ResponsibleQuery.prepare(sStatement);
    m_ResponsibleQuery.bindValue(":currentTcId", uiId);
    m_ResponsibleQuery.exec();
    QTextCodec::setCodecForCStrings(QTextCodec::codecF orName("UTF-8"));

    if (checkForErrors(&m_ResponsibleQuery, "Error while fetching the testcase rel. responsibles!",parent))
    return vResponsibles;
    else
    {
    while(m_ResponsibleQuery.next())
    {


    vResponsibles.push_back
    (
    new Responsible
    (
    m_ResponsibleQuery.value(0).toInt(), //id
    m_ResponsibleQuery.value(1).toString(), //firstName
    m_ResponsibleQuery.value(2).toString(), //lastName
    m_ResponsibleQuery.value(3).toString(), //alias
    m_ResponsibleQuery.value(4).toString(), //eMail
    m_ResponsibleQuery.value(5).toString(), //phone
    m_ResponsibleQuery.value(6).toString(), //division
    m_ResponsibleQuery.value(7).toString(), //comment
    DBM_getTestCaseRelResponsibleFunctions
    (
    m_ResponsibleQuery.value(0).toInt(),
    uiId,
    parent
    ) // function
    )
    );
    }
    return vResponsibles;
    }

    Does anyone have suggestions what I should use to get correct names? Any replies are welcome

    Thanx

  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: Reading umlaut letters from sqlite database

    Which version of SQLITE? How did you enter the data into the database? Don't use a separate text codec, the driver for sqlite should convert the data for you.

  3. #3
    Join Date
    Nov 2006
    Posts
    72
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Reading umlaut letters from sqlite database

    version is sqlite 3. I have already received database with names inside, and saw with different sqlite browsers that names are there and are entered correctly.

  4. #4
    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: Reading umlaut letters from sqlite database

    Does removing the extra codec help?

  5. #5
    Join Date
    Nov 2006
    Posts
    72
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Reading umlaut letters from sqlite database

    No. Actually, the first code I recieved didn't have that extra codec call. I added it, but it made no diference. Any more ideas?

  6. #6
    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: Reading umlaut letters from sqlite database

    Are you sure the data in the database is encoded in UTF-8?

  7. #7
    Join Date
    Nov 2006
    Posts
    72
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Reading umlaut letters from sqlite database

    As far as I know, Sqlite operate with UTF-8 encoding. Is there any way I can check that, and can you suggest me ony other encoding I could try? (I think that that could be checked with changing codec call in my codec, by trial and error repeating).

  8. #8
    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: Reading umlaut letters from sqlite database

    I had problems with SQLite and Qt myself and in the end it proved that the SQLite database was not UTF-8 encoded after all. So try fetching the data with some other mechanism (but not the sqlite3 console, it doesn't convert between local and utf - that was the base of my problems) and see if they are utf-8 encoded.

  9. #9
    Join Date
    Nov 2006
    Posts
    72
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Reading umlaut letters from sqlite database

    Thank you for your fast reply, but I didn't understand completely what you wrote. Can you go in more detail please? Which other mechanism to fetch data? I'm a bit confused, sorry.

  10. #10
    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: Reading umlaut letters from sqlite database

    Quote Originally Posted by Djony View Post
    Which other mechanism to fetch data?
    SQLite C API.

  11. #11
    Join Date
    Nov 2006
    Posts
    72
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Reading umlaut letters from sqlite database

    You mean, to use sqlite c api (in some simple application) to read data from database and see are they in UTF-8 encoded?

  12. #12
    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: Reading umlaut letters from sqlite database

    Yes. That's exactly what I mean.

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.