SQlite and scandinavian characters

Creating desktop or client-server database solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
ibe
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 61
Joined: Sun Oct 04, 2009 12:15 pm

SQlite and scandinavian characters

Post by ibe » Wed Nov 18, 2009 6:57 pm

How should I store scandinavian characters of strings (öäå) inside an SQlite database. If I store them as such from RR I can do exact string searches, ie.
select * from food where name like "pä"
will return all strings starting with pä and Pä, but not pÄ or p
PÄ. So I probably should convert them when storing the values originally.

Is the recommended method to store the values in SQlite as unicode?

Any pointers appreciated.

Thanks,

Ismo

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Contact:

Post by Janschenkel » Wed Nov 18, 2009 8:44 pm

This sounds like a problem in SQLite to me, if its case insensitive sort doesn't work for uppercase/lowercase special characters with diacritics.

The only alternative I can give you, is to store an additional 'normalized' copy of the string in another column of the same table; in that 'normalized' copy, you replace all characters with their uppercase version, stripping off the diacritical part.
So àbçéèöäå would become ABCEEOAA, and naturally you would also have to use a similar 'normalized' version of your search term in your SELECT query. The downside being that it is a bit more work to program, and a search for pä would also turn up pa, pà and so forth - but some people would call this a very useful feature.

HTH,

Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

ibe
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 61
Joined: Sun Oct 04, 2009 12:15 pm

Post by ibe » Wed Nov 18, 2009 8:53 pm

Thanks Jan, I've been working on this and found a solution that works for me. If I store the strings as ISO (I do a MacToISO before storing and ISOtoMac after I retrieve it) then everything works for at least scandinavian characters.

So now I can do sql 'like' searches that are case insensitive. Only downside is that I'll have to check if my app is running on a mac and then do the extra string conversions.

My 2 cents,

Ismo

Post Reply