Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6971461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:50:35+00:00 2026-05-27T16:50:35+00:00

I have a problem with the SQLite3 C API. I’m trying to read some

  • 0

I have a problem with the SQLite3 C API. I’m trying to read some information from the places.sqlite database that Firefox uses to store many things. What I’m interested in is to retrieve the last visited website and the window title associated.

I wrote this piece of code:

query = "SELECT `url`, `title` FROM `moz_places` WHERE `id`=(SELECT `place_id` FROM `moz_historyvisits` ORDER BY `id` DESC LIMIT 1)";
stmt = NULL;
if (sqlite3_prepare_v2(db, query.c_str(), strlen(query.c_str()) + 1, &stmt, NULL) != SQLITE_OK)
    cerr << sqlite3_errmsg(db) << endl;
else
{
    while ((ret = sqlite3_step(stmt)) == SQLITE_ROW)
        cout << sqlite3_column_text(stmt, 0) << endl << sqlite3_column_text(stmt, 1) << endl;
    if (ret != SQLITE_DONE)
        cerr << sqlite3_errmsg(db) << endl;
}

When there are no special characters it works fine, but if the window title contains “é”, “è” or “•” for example, I get those wonderful characters “é”, “è” or “•”.
I did some research and found that some people actually got non-UTF8 encoded databases. So I checked the places.sqlite database encoding with both SQLite Manager and the “PRAGMA encoding” request, both say that it is UTF-8 encoded.
Then I created my own database, encoded in UTF-8, entered some special characters in a table and it didn’t work either. So I thought that maybe QtCreator (which I’m using) can’t show special characters, I tried to get the foreground window title with GetForegroundWindow() and print it in QtCreator application output. It successfully showed the special characters of some window titles.

What am I missing here ?

Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T16:50:35+00:00Added an answer on May 27, 2026 at 4:50 pm

    Weel, seems like I managed to fix that problem by using this function I wrote:

    wchar_t             *char_to_wchar(const char *str)
    {
        wchar_t         *wbuf;
        int             wsz;
    
        if (!str)
             return (NULL);
        wbuf = NULL;
        wsz = MultiByteToWideChar(CP_UTF8, 0, str, -1, wbuf, 0);
        if (wsz)
            wbuf = (wchar_t*)malloc(wsz * sizeof(*wbuf));
        else
            cerr << "MultiByteToWideChar fail getting required size: " << GetLastError() << endl;
        if (wbuf)
        {
            if (!MultiByteToWideChar(CP_UTF8, 0, str, -1, wbuf, wsz))
                cerr << "MultiByteToWideChar fail: " << GetLastError() << endl;
        }
        return (wbuf);
    }
    

    Still, I found it weird that with a function like GetWindowText() I manage to correctly print “é” and other caracters from a simple char *, but here I must use a wchar_t *…
    Well, it works at least, let’s hope it was the best solution 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have data stored in a sqlite3 database and have several places that I
I have a problem displaying the swedish characters åäö, read from my database, in
I have a problem with deleting a record from my SQLite3 database: conn =
i have a problem that i can't solve ! (sqlite3, but i think it
I have problem in some JavaScript that I am writing where the Switch statement
Here's my problem, I have one sqlite memory database by using QSql . I
I have a relatively extensive sqlite database that I'd like to import into my
i have a huge problem with my sqlite3 database on the iphone sdk 4.
I have an application that is finished except for the problem i am trying
I have big problem. I have 100000 rows in my database(sqlite). I can't reduce

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.