Search with accents in SQL Yoga

This is the place to post technical queries about SQL Yoga

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, trevordevore

Post Reply
cbarbal
Posts: 94
Joined: Fri May 08, 2015 5:04 pm

Search with accents in SQL Yoga

Post by cbarbal » Thu Oct 11, 2018 11:42 am

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

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 914
Joined: Sat Apr 08, 2006 3:06 pm
Location: Overland Park, Kansas
Contact:

Re: Search with accents in SQL Yoga

Post by trevordevore » Thu Oct 11, 2018 12:16 pm

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?
Trevor DeVore
ScreenSteps - http://www.screensteps.com

Levure Application Framework: https://github.com/trevordevore/levure
LiveCode Resources for Developers: http://livecode.bluemangolearning.com

cbarbal
Posts: 94
Joined: Fri May 08, 2015 5:04 pm

Re: Search with accents in SQL Yoga

Post by cbarbal » Thu Oct 11, 2018 2:40 pm

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

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 914
Joined: Sat Apr 08, 2006 3:06 pm
Location: Overland Park, Kansas
Contact:

Re: Search with accents in SQL Yoga

Post by trevordevore » Thu Oct 11, 2018 2:55 pm

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.
Trevor DeVore
ScreenSteps - http://www.screensteps.com

Levure Application Framework: https://github.com/trevordevore/levure
LiveCode Resources for Developers: http://livecode.bluemangolearning.com

cbarbal
Posts: 94
Joined: Fri May 08, 2015 5:04 pm

Re: Search with accents in SQL Yoga

Post by cbarbal » Thu Oct 11, 2018 3:32 pm

Thank you very much Trevor,

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

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 914
Joined: Sat Apr 08, 2006 3:06 pm
Location: Overland Park, Kansas
Contact:

Re: Search with accents in SQL Yoga

Post by trevordevore » Thu Oct 11, 2018 3:35 pm

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.
Trevor DeVore
ScreenSteps - http://www.screensteps.com

Levure Application Framework: https://github.com/trevordevore/levure
LiveCode Resources for Developers: http://livecode.bluemangolearning.com

Post Reply

Return to “SQL Yoga”