views:

151

answers:

1

I have a Sqlite database that has ClipArt tags in, we are translating that database to Swedish however my database query now does not return a result if the characters are non-English British.

For example, fisk == fish and that works perfectly, however öst == east but that fails.

I am constructing the query in a QString from a QLineEdit:

 sqlStatement += QString(" FileID IN (SELECT TLFileID FROM tblTags "
   " INNER JOIN tblTagLinks ON tagId = TLTagId "
   " WHERE tagLanguage LIKE '%1' "
   " AND (tagName LIKE '%2' OR tagName LIKE '%2s' "
   " OR tagLangSWEDISH LIKE '%2' "
   " OR tagLangFINNISH LIKE '%2' "
   " OR tagLangITALIAN LIKE '%2' ))").arg(defaultLanguage, tag);

and then converting it to a QSqlQuery:

qryFiles.prepare(sqlStatement);

if(!qryFiles.exec())

I know the database has the chars because I have been importing and exporting the data to CSV for the translators to translate, using a Sqlite admin tool and Excel.

Do I have to open the database in a special way?

I am using Qt 4.5.2, Windows XP, VS2008, Sqlite 3.5.1

+1  A: 

I know it might be obvious, but did you check what character sets your db and your application use? I would guess that you're using native Windows coding in one and UTF8 in the other.

Sorry for the obvious answer, but that's the cause of most of my internationalization problems.

zarzych
What would I check for the windows encoding? Would this be a compiler setting?
Phil Hannent
@Phil: You're binding value of tag variable into your query. Do you set value of tag in code or is it taken from user input? If it's set in the code then it has your editor's encoding. If it's taken from user (gui), then it has system encoding. I don't know what Windows language you're using but you should be able to google the correct encoding.
zarzych
Turns out that I was using Excel to create the csv file which was Latin1, the SQL Admin tool I was using was reporting the chars as correct however they were not UTF. I used OpenOffice, selected UTF8 as the export value, imported using the tool, the chars looked wrong but to my Qt application it work perfectly. Many thanks.
Phil Hannent