0

I have a sqlite table which is encoded in utf-8. The firefox add-on SQLite Manager shows me all the signs correct and the pragma encoding says encoding utf8, too.

How to get this data correct encoded and shown in a c++ program ?
This is the code i have:

sqlite3 * dataBase;
const char * data;
sqlite3_stmt * statement;
int row = 0;
sqlite3_open("C:\\Users\\david\\Documents\\Visual Studio 2013\\Projects\\Database1\\Database1\\Spieler.sqlite", &dataBase);
data = "SELECT LigaName,LigaID FROM Liga";
sqlite3_prepare_v2(dataBase, data, strlen(data) + 1, &statement, NULL);

while (1)
{
    int s;

    s = sqlite3_step(statement);
    if (s == SQLITE_ROW)

    {
        int bytes;

        bytes = sqlite3_column_bytes(statement, 0);
        std::string ligaName = std::string(reinterpret_cast<const char*>(
            sqlite3_column_text(statement, 0)));
        std::string ligaIDString = std::string(reinterpret_cast<const char*>(
            sqlite3_column_text(statement, 1)));
    }
}

Problem is the string is not encoded as utf-8, of course, so now when i cout the string with this code

std::cout << ligaName << std::endl;
std::cout << "ligaName: " << sqlite3_column_text(teamStatement, 0) << std::endl;

i got from the sqlite3_column_text i see something like

  • ü instead of ü
  • ä instead of ä
  • ö instead of ö

All of this umlauts are shown correct in SQLite Manager.
After some research i found out that this seems to be the correct utf8-bytes encoded as windows-1252.
How to display the correct german umlauts ? I use Visual Studio 2013 on Windows7

EDIT :
Another point maybe important: When i open the database in notepad++ it shows me encoding ANSI and i see the same weird signs as mentioned before.
When i switch to UTF-8 everthing looks fine but i cant save this encoding.

jimbo999
  • 80
  • 7
  • 1
    Of course it is encoded as UTF-8. Just whatever you're using to display it doesn't understand UTF-8. Unfortunately we can't help much with that unless you show us how you're displaying it. – Dark Falcon Jul 30 '14 at 18:00
  • See [Unicode characters in Windows command line - how?](http://stackoverflow.com/questions/388490/unicode-characters-in-windows-command-line-how). – CL. Jul 30 '14 at 19:37

0 Answers0