#1 2014-09-05 10:12:22

juwo
Member
Registered: 2014-09-05
Posts: 21

CreateAndFillPrepare and national chars

Hi,
First many thanks for great framework.
I use old delphi version (6) and have a problem with polish national chars.
Field is defined as fNazwa: RawUTF8;
How to correctly pass params in CreateAndFillPrepare when field nazwa have chars like ą, ś, ć. If field contain this chars CreateAndFillPrepare return empty list. I try StringToUTF8 - not work.

Regards

Offline

#2 2014-09-05 11:01:43

juwo
Member
Registered: 2014-09-05
Posts: 21

Re: CreateAndFillPrepare and national chars

After some tests:
This work fine:
sza := TSQLSzablon.CreateAndFillPrepare(form1.Database, 'Nazwa LIKE ?',[nazwa_wzoru]);
this not:
sza := TSQLSzablon.CreateAndFillPrepare(form1.Database, 'Nazwa = ?',[nazwa_wzoru]);
(only with national chars, without work as expected)

Offline

#3 2014-09-05 15:49:08

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,275
Website

Re: CreateAndFillPrepare and national chars

StringToUTF8() should convert your Win1251 string into UTF-8 RawUTF8.
We have several users from easter countries, which rely heavily on mORMot with such encoding, and great success.
Try using WideString instead.

Are your using the latest version of the framework (i.e. 1.18 unstable version from nightly zip)?
What is your database back-end? Does it work with SQLite3 (which is UTF-8 nativly so would not have any problem with national chars). Perhaps this is DB-related, between the mORMot ORM and the SynDB units and the external DB.
Have you code to show which reproduce the issue?

Offline

#4 2014-09-05 18:26:05

juwo
Member
Registered: 2014-09-05
Posts: 21

Re: CreateAndFillPrepare and national chars

Thanks for reply,
I tested it on last nightly zip with the same result. "LIKE" return record "=" not. I prepare simply project with my SQLite db: https://dl.dropboxusercontent.com/u/23593726/test.zip

Best Regards

Offline

#5 2014-09-06 06:54:57

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,275
Website

Re: CreateAndFillPrepare and national chars

So in your case:

sza := TSQLSzablon.CreateAndFillPrepare(form1.Database, 'Nazwa = ?',[StringToUTF8(nazwa_wzoru)]);

does not work?

If I take a look at the Szablon table in the supplied SQlite3 file, the "Nazwa" columns seems not properly encoded.
What is stored is not valid UTF-8.
Just use any SQLite3 tool, like our SynDBExplorer or the SQliteSpy freeware.

Your problem comes from the fact that you did write some raw "string" content into the DB, without proper conversion to UTF-8 before.
You should use UTF8ToString(aMyPolishString) when setting any TSQLRecord field from a VCL string, in Delphi 6, before calling aRest.Add(aMyRecord).
Since Delphi 2009, since string=UnicodeString, you may set directly such a string to a RawUTF8 field, but not with non-unicode version of Delphi.

Offline

#6 2014-09-06 13:17:00

juwo
Member
Registered: 2014-09-05
Posts: 21

Re: CreateAndFillPrepare and national chars

Thanks for explanation and many thanks for your effort.

PS
I made small donation - I promise more when I will sell my first mormot powered application

Offline

#7 2014-09-06 13:39:40

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,275
Website

Re: CreateAndFillPrepare and national chars

Thanks a lot!
smile

And do not forget to list your app on mORMot ShowCase, if you wish to.
See http://blog.synopse.info/post/2014/08/2 … t-ShowCase
wink

Offline

Board footer

Powered by FluxBB