Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ SQL » SQLArray + Like() + Accents problem
SQLArray + Like() + Accents problem [message #30791] Sun, 23 January 2011 00:38 Go to next message
alex100 is currently offline  alex100
Messages: 118
Registered: November 2007
Experienced Member
Hi all

Suppose the clients table (SQLite) has the following contents on field (column) name:

Júlio Ferraz
Júlia Sotinova
Jusefina Braz
Jumila Carter

Now, I want to select names by using the first two chars.
I used a SQLArray (named dbgrid) and I am using the query() method to issue the Where clause.
I am formating the where clause like this:

(Supose strIniciais String variable has the contents of an editbox used to read the two characters)

SqlBool where1;
where1 = Like(Name,Format("%s%s%%",strIniciais.Mid(0,1),strIniciais.Mid(1,1)));
dbgrid.SetOrderBy(Name);
dbgrid.Query(where1);

If I write Ju in editbox the SQLArray shows
Jusefina Braz
Jumila Carter

which is correct.

If I write Jú (u with an accent) in editbox the SQLArray shows nothing.
Why?

I used a client GUI for SQLite, I opened the database and issued the following SQL statment:
Select * from clients where Name like 'Jú%';

(u with an accent)

and it worked. So it seems that the problem is on UPP c++ code.

Any help?

Thanks a lot

Alex

Re: SQLArray + Like() + Accents problem [message #30793 is a reply to message #30791] Sun, 23 January 2011 12:42 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
I think the most likely cause is encoding mismatch...
Re: SQLArray + Like() + Accents problem [message #30803 is a reply to message #30793] Sun, 23 January 2011 19:30 Go to previous messageGo to next message
alex100 is currently offline  alex100
Messages: 118
Registered: November 2007
Experienced Member
Do you mean set SQLArray to "utf8" ?
But how?
Thank you

Alex
Re: SQLArray + Like() + Accents problem [message #30859 is a reply to message #30803] Tue, 25 January 2011 13:07 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Either your app encoding is not utf-8 ('SetDefaultCharset'), or Sqlite3 encoding is not utf-8 (to tell the truth, right now I do not remember how encoding in Sqlite3 works...)

That said, other DB engines transcode from app encoding to db encoding and back. So perhaps Sqlite3 should do that too.
Re: SQLArray + Like() + Accents problem [message #30860 is a reply to message #30859] Tue, 25 January 2011 14:28 Go to previous messageGo to next message
alex100 is currently offline  alex100
Messages: 118
Registered: November 2007
Experienced Member
My app is utf-8 enabled. It is the SQLite that it is not...

I do not know how to set it. If someone knows, please let me know.


Alex
Re: SQLArray + Like() + Accents problem [message #30867 is a reply to message #30791] Wed, 26 January 2011 10:59 Go to previous messageGo to next message
alex100 is currently offline  alex100
Messages: 118
Registered: November 2007
Experienced Member
I replaced the SQLArray control by the ArrayCtrl. Now I get information from db using sql statments and fill grid by hand ad everything is ok.
It seems that it is a problem of SQLArray, isnt it?

Alex
Re: SQLArray + Like() + Accents problem [message #30899 is a reply to message #30867] Fri, 28 January 2011 01:36 Go to previous message
alex100 is currently offline  alex100
Messages: 118
Registered: November 2007
Experienced Member
Well, it stoped from work again. IT just works while I have a free SQLITE GUI application used to launch sql statments to the db. It seems that this application temporarly modifies the SQLITE engine, i dont know how...

But I realized that SQLITE do not supports unicode on Like() statement. (http://www.sqlite.org/faq.html and search for unicode)

Someone wrote a .h and .c file to add support for unicode to SQLITE. the files are here:
http://ioannis.mpsounds.net/blog/2007/12/19/sqlite-native-un icode-like-support/?dl=sqlite3_unicode.zip
With this zip we can compile a .lib, a .dll or use the files directly on a project. As far as I realized, when using directly on a project, only the .c is needed.

I added the .c file to the project and called the functions
sqlite3_unicode_load();
sqlite3_unicode_free();
in the GUI_APP_MAIN block.
The project compiles well but when linking it does not finds the implementation of those functions.

How can I include this .c file in my project and call the functions? A little sample program would be very appreciated.


I tried also generate the lib file but compiler always says that it cant find ~
sqlite3_unicode_load();
sqlite3_unicode_free();

event specifying the .lib file.

Thanks

Alex
Previous Topic: SQLite3, ODBC and UTF-8
Next Topic: Simple SQL question
Goto Forum:
  


Current Time: Fri Mar 29 02:36:40 CET 2024

Total time taken to generate the page: 0.01076 seconds