Page 1 of 1

Search with accents in SQL Yoga

Posted: Thu Oct 11, 2018 11:42 am
by cbarbal
Hi all,

I'm trying out the French Regions demo and trying to find cities with an accent can not find them.Is there any way to do it?

Thanks in advance,

Carles

Re: Search with accents in SQL Yoga

Posted: Thu Oct 11, 2018 12:16 pm
by trevordevore
Hi Carles - searching for accented characters can work. There is most likely a text encoding issue. Which version of LC are you using and which string are you searching for?

Re: Search with accents in SQL Yoga

Posted: Thu Oct 11, 2018 2:40 pm
by cbarbal
Hi Trevor,

LC 9.0.0, MacOX 10.13.6 Spanish version.

Some of the cities I've tried, they're all in the database and the accents look good: Belvédère, Orgnac-sur-Vézère, Castellet-lès-Sausses, Abergement-Clémenciat, Ambléon.

Regards,

Carles

Re: Search with accents in SQL Yoga

Posted: Thu Oct 11, 2018 2:55 pm
by trevordevore
I took a look at the code and here is what I found out. The sample stack uses the text of the search field when generating the query. In LC 9 this will encode an é as unicode. SQLite is expecting a UTF-8 string so you need to make the change accordingly.

1. edit script of group "TownsGroup"
2. Change line 66 to this:

Code: Select all

 sqlyoga_splitUserSearchString(textencode(the text of field "SearchName", "utf8"))
I get a search result when searching for Ambléon after making that change.

Re: Search with accents in SQL Yoga

Posted: Thu Oct 11, 2018 3:32 pm
by cbarbal
Thank you very much Trevor,

Works correctly. If I save text with accents I'll have to change texencode with texdecodee?

Re: Search with accents in SQL Yoga

Posted: Thu Oct 11, 2018 3:35 pm
by trevordevore
You always need to ensure that you match the encoding used in LiveCode to the encoding used in the database. When storing data in a UTF-8 column you need to encode it as UTF-8 before passing it to SQL Yoga. I like to work in LC's native encoding when working with data within LC. I then convert to UTF-8 when inserting, updating, or searching the database.