Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Highlighted
New Contributor
Posts: 7
Registered: ‎12-05-2013
My Device: Z10
My Carrier: Yoigo

Re: insert QString to Sqlite encoding

sorry, I click on "Quick Reply" and thought it would show with the reply Smiley Wink

 

I mean where is the question Incogruous said: "Dude! I think a saw a similar question in the SQLite3 users group. The OP was asking about SQLite3 locale compatabilty with his/her machine.  I suggest to try that group as well, they just might have the answer. Best wishes"

 

thanks!

Developer
Posts: 16,986
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: insert QString to Sqlite encoding

As i can insert and retrieve the test string without any issue (and you seem to be able to do that as well) the error is most likely not with sqllite.

I would suggest to test your code step by step and check where it fails.
I don't have a web service returning special characters, so you'll have to test that yourself.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 1,158
Registered: ‎03-20-2013
My Device: Red LE Developer Z10
My Carrier: Fido

Re: insert QString to Sqlite encoding

I have just spent a few days struggling with XML encoding issues in my desktop Rainmeter plugin, and I can confirm it can create a host of tricky problems when dealing with foreign languages.

 

Have you tried using PRAGMA ENCODING="UTF-8"? It is possible this will only work if you specify it while the db is being created though, so YYMV.

 

Also, this thread goes into great detail about this issue, although it is talking about a legacy BBOS version. That said, it could be useful.


RuiAlonso wrote:

I've been developing for BB10 since last year, but I'm new in this forum so hi to everyone!

 

I have a problem saving data to Sqlite. I read a xml feed encoding in utf-8 with portuguese characters, I show all strings ok but when I insert them into database encoding fails. Here is my code:

 

once I haver received xml

void updater(QVariantMap responseData) {
    …
    …
    QVariantList championshipsList = responseData["Campeonato"].toList();
    for(int i = 0; i<championshipsList.length(); i++) {
        QVariantMap auxChampionship = championshipsList.at(i).toMap();
        Championship championship;
        championship.id = auxChampionship["Id"].toString().trimmed();
        championship.name = auxChampionship["Nome"].toString().trimmed();
        //at this point, name show right! ex: "Seleção Brasileira"
debug("Championship ID:"+championship.id+" Name:"+championship.name); if(!_databaseManager->existsChampionship(championship)) _databaseManager->insertChampionship(championship); else _databaseManager->updateChampionship(championship); } }

 

and insert/update database:

bool DataBaseManager::updateChampionship(Championship championship) {
    QString query("UPDATE championships SET 'name' = :name WHERE id = :id;");
 
    QVariantList l;
    l << championship.name << championship.id;
        DataAccessReply reply = _sqlconnection->executeAndWait(query, l);
 
        if (reply.hasError()) {
            gerror(QString("SQL Error: %1").arg(reply.errorMessage()));
            gerror("Query: " + query);
            return false;
        } else {
//SqlConnection *_sqlconnection in .hpp _sqlconnection->endTransaction(reply.id()); //info("Championship " + championship.name + "-" + championship.name + " inserted into database."); } return true; }

 

all data stored in database have wrong encoding (like "Seleção Brasileira"). 

I don't know what happen, because if I put "name" by constant string like:

 

championship.name = QString::fromUtf8("Seleção Brasileira");

 it works fine!

 

anyone knows how to fix it?

 

Thanks!!

 






Developer of Built for BlackBerry certified multiFEED RSS/Atom feed reader and aggregator.  multiFEED Icon

Play nice: Clicking Like Button on posts that helped you not only encourages others to continue sharing their experience, but also improves your own rating on this board. Also, don't forget to accept a post if it solves your problem or answers your question.
New Contributor
Posts: 7
Registered: ‎12-05-2013
My Device: Z10
My Carrier: Yoigo

Re: insert QString to Sqlite encoding

Hi simon_hain,

 

you can test it with these feed http://www.achofacil.com.br/igmobile/listacampeonatos.php there you will see championships with latin characters

 

thanks!