SQLite and Unicode

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
danielrr
Posts: 140
Joined: Mon Mar 04, 2013 4:03 pm

SQLite and Unicode

Post by danielrr » Mon Mar 14, 2016 2:16 am

First, my apologies if this question is trivial or if it's been answered 100 times already.

I have a sqlite database with text in unicode utf16. When I use it with programs like SQLiteStudio there's no problem with the database. However, from LiveCode I can't query the database for text in Unicode (it returns empty). And when I query the DB using numeral fields, the Unicode text (is Greek, if you are wondering) are rubbish.

Again, I am afraid this can be a quite trivial question.

I am using LC 7.1.2 on a Mac (OS X 10.11).

Best,

Daniel

danielrr
Posts: 140
Joined: Mon Mar 04, 2013 4:03 pm

Re: SQLite and Unicode

Post by danielrr » Mon Mar 14, 2016 9:25 am

OK, I'll answer myself (and anybody with the same problem): before querying the database (let's say data was introduced in UTF8) you "textencode" the string to search with a SELECT statement, like

Code: Select all

put textEncode(searchText,"UTF8") into searchText
and you textdecode the results

Code: Select all

put textDecode(textFound,"UTF8") into textFound
That makes the trick

Daniel

danielrr
Posts: 140
Joined: Mon Mar 04, 2013 4:03 pm

Re: SQLite and Unicode

Post by danielrr » Mon Mar 14, 2016 11:25 am

Thanks Daniel. It works!

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7210
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: SQLite and Unicode

Post by jacque » Mon Mar 14, 2016 4:26 pm

Lol. So the reason I can't always answer my own questions is because I forget to thank myself. :-)
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

phaworth
Posts: 592
Joined: Thu Jun 11, 2009 9:51 pm

Re: SQLite and Unicode

Post by phaworth » Mon Mar 14, 2016 8:28 pm

Don't forget to textEncode any data you INSERT or UPDATE into the database.
Pete

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”