Page 1 of 1

Encoding problems with SQLite

Posted: Tue Jan 27, 2015 10:09 pm
by Ultravibe
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?

Re: Encoding problems with SQLite

Posted: Wed Jan 28, 2015 6:10 pm
by MaxV
Livecode 7 supports russian characters.
SQLite supports only ASCII characters.
Use base64Encode() and base64decode() functions before transfer to/from SQLite db.

Re: Encoding problems with SQLite

Posted: Wed Jan 28, 2015 6:22 pm
by MaxV
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>

Re: Encoding problems with SQLite

Posted: Wed Jan 28, 2015 7:54 pm
by phaworth
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