Query with accents

The offical for ZeosLib 7.3 Report problems, ask for help, post proposals for the new version of Zeoslib 7.3/v8
Quick Info:
-We made two new drivers: odbc(raw and unicode version) and oledb
-GUID domain/field-defined support for FB
-extended error infos of Firebird
-performance ups are still in queue
In future some more feature will arrive, so stay tuned and don't hassitate to help
Post Reply
hamacker
Junior Boarder
Junior Boarder
Posts: 37
Joined: 13.10.2021, 15:15

Query with accents

Post by hamacker »

ZConnection has ClientCodePage=WIN1252 and ControlsCodePage=cGET_ACP. Database FirebirdSQL v5. Zeos 8.0.0-beta. Lazarus 3.2.
No error with accents in insert or update operations, data inside database are fine, but when I try do get using query as:
select a.* from almox a
where
(exists(
select * from almox_tags z
where z.coditem_almox=a.coditem_almox and z.tagname='vergalhão' <-- accent
))
and (a.status='A')

No records are found, but when I copy and paste and try again using flamerobin/ibexpert, records are found.
I think that my query are processing using unicode and because of thism FAILs. I think that´s the problem because when I do SQL.SaveToFile(...) the experted file are unicode format.

How Can I fix this?
hamacker
Junior Boarder
Junior Boarder
Posts: 37
Joined: 13.10.2021, 15:15

Re: Query with accents

Post by hamacker »

Reply my self,

Change
RawCharacterTranslitarateOptions.encoding:=encDefaultSystemCodePage;
SQL:=true;

Now, it´s works!
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1956
Joined: 17.01.2011, 14:17

Re: Query with accents

Post by marsupilami »

Hello hamacker,

I wonder why you have set ControlsCodePage to cGET_ACP? With Lazarus applications it usually should be set to cCP_UTF8?

Do you develop an console application?

Best regards,

Jan
hamacker
Junior Boarder
Junior Boarder
Posts: 37
Joined: 13.10.2021, 15:15

Re: Query with accents

Post by hamacker »

Hi, Jan.

No, I dont dev console application, not yet.
Initially was cCP_UTF8, but when I found problems with Query.sql.text, I try a lot of combinations, and so... at final point I found this conbination:
ClientCodePage=WIN1252
ControlsCodePage=cGET_ACP.
RawCharacterTranslitarateOptions.encoding:=encDefaultSystemCodePage;
RawCharacterTranslitarateOptions.SQL:=true;

But with your tip, I wil revert ControlsCodePage to cCP_UTF8 and test again.
marsupilami wrote: 27.03.2024, 09:45 Hello hamacker,

I wonder why you have set ControlsCodePage to cGET_ACP? With Lazarus applications it usually should be set to cCP_UTF8?

Do you develop an console application?

Best regards,

Jan
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1956
Joined: 17.01.2011, 14:17

Re: Query with accents

Post by marsupilami »

Hello hamacker,

I think the best way to operate on Lazarus is to work with UTF8 on all levels:
ClientCodePage=UTF8
ControlsCodePage=cCP_UTF8

This way you don't have to change the RawCharacterTranslitarateOptions from the defaults and no character set transliteration needs to be done in your program or Zeos. Firebird will do the character set transliteration for you automatically.

For one of my service applications I decided to also switch the RTL in FPC to use UTF8 on Windows by calling SetMultiByteConversionCodePage(CP_UTF8), so I can use UTF8 on all levels of the program again.

Best regards,

Jan
hamacker
Junior Boarder
Junior Boarder
Posts: 37
Joined: 13.10.2021, 15:15

Re: Query with accents

Post by hamacker »

Thanks for helping.

Windows is a mess, cp450 on terminal, win1252(ansi) on UI and need to be careful with editors, Delphi save our code (and strings) as Ansi, Lazarus save as unicode, so... Windows is not for amateurs.
Post Reply