Encoding problems with SQLite

Creating desktop or client-server database solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Ultravibe
Posts: 62
Joined: Sat Jan 17, 2015 12:06 pm

Encoding problems with SQLite

Post by Ultravibe » Tue Jan 27, 2015 10:09 pm

Hi there!
I use SQLite to store the data (few columns, named Number, Name, Amplua etc).
And first problem is:
My LiveCode application don't "understand" the russian characters. Anyway:
1) If i put data by entering text in LiveCode and pass it to database, or
2) if i put data into database by SQLite Expert personal and read it from database by LiveCode application.
In both situations, russian characters (which readed from database) are displayed incorrect.

Second problem is:
I use casparCG to display animated titles (flash templates with dynamic text). When i try to assign text with russian charcters to dynamic text field, it's displayed incorrectly.

Both problems, i guess, because of troubles with coding

What am i do?

MaxV
Posts: 1579
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: Encoding problems with SQLite

Post by MaxV » Wed Jan 28, 2015 6:10 pm

Livecode 7 supports russian characters.
SQLite supports only ASCII characters.
Use base64Encode() and base64decode() functions before transfer to/from SQLite db.
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

MaxV
Posts: 1579
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: Encoding problems with SQLite

Post by MaxV » Wed Jan 28, 2015 6:22 pm

Otherwise use the htmltext property of the fields. Probably the htmltext is faster, simpler and preserve font format.

Снег в вашей части? = <p><b>&#1057;&#1085;&#1077;&#1075; &#1074; &#1074;&#1072;&#1096;&#1077;&#1081; &#1095;&#1072;&#1089;&#1090;&#1080;?</b></p>
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

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

Re: Encoding problems with SQLite

Post by phaworth » Wed Jan 28, 2015 7:54 pm

By default, all data in SQLite is UTF8 encoded but you can also create a UTF16 encoded database if you need to. So yes, Russian characters can be handled as can any other unicode text.

Here's the code to do it, with thanks to Devin Assay.

If you have read your Russian text from the database into a variable named "tRussFldFromDB" and you want to display it in a field named "russStuff", the code is:

set the unicodeText of fld “russStuff” to uniencode(tRussFldFromDB,”utf8”) --for pre LC 7.0
put textDecode(tRussFldFromDB,”utf8”) into fld “russStuff” -- for LC 7.0+

To get Russian text from the field and put it into your database:

put unidecode(the unicodeText of fld “russStuff","utf8") into tRussTxt --for pre LC 7.0
put textEncode(the text of fld “russStuff”,”utf8”) into tRussTxt --for LC 7.0+

Pete
lcSQL Software

Post Reply

Return to “Databases”