I am creating a SQLite database from qt like this:
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE", mConnectionName);
db.setDatabaseName("myDattabse.DB");
if (!db.open()) {
return false;
}
When trying to insert Macedonian characters in the SQLite database, the characters are inserted as ???.
According to this link http://www.qtcentre.org/threads/26202-SQLite-connection-and-encoding?highlight=unicode+and+sqllite , I need to create my database with utf-16 encoding to solve my problem. SQLite default encoding is utf-8. How can I do that? Where to specify this option in my code?
From my understanding you should be fine with UTF8, pls, check if an example below would work for you:
output should be:
now back to your original question, I believe you can have you sqlite database in UTF-16 as default encoding if the database is opened with sqlite3_open16 function. According to QT source code (qsql_sqlite.cpp QSQLiteDriver) they are using sqlite3_open_v2 function to open the connection to database which is UTF-8, but again, there is nothing wrong with it for working correctly with Cyrillic characters.
hope this helps, regards