PDA

View Full Version : SQLite encoding problem



cevou
26th September 2009, 23:18
Hi everyone,

I have a problem with selecting German umlauts (ä ö ü) from an SQLite-Database.

There is one thing that works an another that doesn't.

Here the working example:


QSqlQuery query;
query.prepare("SELECT name, surname FROM names WHERE nameid=?");
...

This return for example "Max" and "Müller".

BUT if I want to select it in one combined string like this it returns some strange characters.


QSqlQuery query;
query.prepare("SELECT name || ' ' || surname FROM names WHERE nameid=?");
...

In my case this returns "Max M?ller". It's the same dataset just a differen SELECT. What am I doing wrong?

Thanks in advance
Chris

Lykurg
27th September 2009, 10:11
Hi, may it could help if you execute following

PRAGMA encoding = "UTF-8";
and did
SELECT name || surname FROM names WHERE nameid=?
also return a corrupt umlaut?

EDIT: what encoding has your cpp file?

cevou
27th September 2009, 19:45
Hi,

the first solution didn't work.

I think all the cpps are encoded using latin1.

Lykurg
27th September 2009, 22:37
and if you skip the blank in you "concat"? Is the umlaut then also corrupted? Seems to be a problem between your latin1-string and the internal utf8 of sqlite.