[patch_done] IFDEF ZEOS_FULL_UNICODE

The alpha/beta tester's forum for ZeosLib 7.0.x series

Report problems concerning our Delphi 2009+ version and new Zeoslib 7.0 features here.

This is a forum that will be removed once the 7.X version goes into stable!!

Moderators: gto, EgonHugeist, olehs

Locked
mariuszekpl
Senior Boarder
Senior Boarder
Posts: 54
Joined: 30.09.2008, 10:59

[patch_done] IFDEF ZEOS_FULL_UNICODE

Post by mariuszekpl »

I think about IFDEF ZEOS_FULL_UNICODE
What does it mean ?

If i compile ZEOS with ZEOS_FULL_UNICODE
i can't open correctly databases with Latin2 encoding.
I think about "SVN rev. 537."

example code

Code: Select all

{$IFDEF ZEOS_FULL_UNICODE}
    GetPlainDriver.db_execute_imm(GetDBHandle, PAnsiChar(UTF8String (SQL)));
    {$ELSE}
    GetPlainDriver.db_execute_imm(GetDBHandle, PAnsiChar(SQL));
    {$ENDIF}      


If i have LATIN2 databse and ZEOS_FULL_UNICODE
When i execute

INSERT into TABLE_NAME (dane) VALUES ('łęćżę');

My SQL is UTF8String encoding but i need LATIN2 encoding send to PlainDriver

May by wy should change it

Code: Select all

{$IFDEF ZEOS_FULL_UNICODE}
  if WE_WANT_UNICODE = TRUE then
    GetPlainDriver.db_execute_imm(GetDBHandle, PAnsiChar(UTF8String 
  else
    GetPlainDriver.db_execute_imm(GetDBHandle, PAnsiChar(SQL));
(SQL)));
    {$ELSE}
    GetPlainDriver.db_execute_imm(GetDBHandle, PAnsiChar(SQL));
    {$ENDIF}      



or

Code: Select all

{$IFDEF ZEOS_FULL_UNICODE}
    GetPlainDriver.db_execute_imm(GetDBHandle, PAnsiChar(SOME_FUNCTION(SQL)));
    {$ELSE}
    GetPlainDriver.db_execute_imm(GetDBHandle, PAnsiChar(SQL));
    {$ENDIF}      


SOME_FUNCTION - return string in suitable encoding

Sometimes i need open database in LATIN2 and UTF8 in this same project
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Good question... maybe we should rename the compiler directive to DELPHI12_UP, this meaning all Strings are unicodestrings.

Concerning the problem with the encoding of strings sent to the database we must start thinking about how this could be implemented best. If I understand correctly this would require something like replacing UTFString() calls by a function pointer that can be assigned dynamically in function of the required encoding. The assignment of the encoding function should happen on the connection object (dbc layer) I suppose you don't know a trick to let the user choose/type a string value meaning the name of the function to be called to encode the string?

What do you think?

Mark
Image
gto
Zeos Dev Team
Zeos Dev Team
Posts: 278
Joined: 11.11.2005, 18:35
Location: Porto Alegre / Brasil

Post by gto »

Hello there :)

I've created this directive, and it means DELPHI12_UP, indeed. It will really become clearly than ZEOS_FULL_UNICODE.

About the creation of this function to handle encoding, I think it should be thinked a bit. There are DB's in which the unicode support is very bad, and which don't support unicode SQLs (one which is firebird, as long I searched).

It will be very good if we can move all of our code to unicode, but DB's aren't doing this, too. We should take some care on compatibility, to not start to write lots of code on IFDEF, and become with two versions of Zeos, one inside another.

I think we need a planned rework, instead of continuous patching this version.
Use the FU!!!!!IN Google !

gto's Zeos Quick Start Guide

Te Amo Taís!
mariuszekpl
Senior Boarder
Senior Boarder
Posts: 54
Joined: 30.09.2008, 10:59

Post by mariuszekpl »

Can we remove changes from SVN rev. 537. ?
And use this function :
(I dont't test it but should work )

{$IFDEF ZEOS_FULL_UNICODE}
{**
Converts Unicode strings to Ansi (Delphi 2009 Up)
}
function UnicodeToAnsi(const UnicodeString: string): RawByteString;
begin
if WE_WANT_UNICODE = TRUE then
result := Utf8string(UnicodeString)
else
result := AnsiString(UnicodeString)
end;
{$ENDIF}

In this sample WE_WANT_UNICODE is global variable
but we can change it , to use property of connections or datasets
or Something Else.

What do you think?
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Conclusions :
* let's rename the compiler directive (you doing it, gto?)
* avoid conditional code as much as possible
* why revert 537? We should think about the replacement first, I believe. Or does it make the situation worse than before?

Mark
Image
gto
Zeos Dev Team
Zeos Dev Team
Posts: 278
Joined: 11.11.2005, 18:35
Location: Porto Alegre / Brasil

Post by gto »

mdaems wrote:Conclusions :
* let's rename the compiler directive (you doing it, gto?)
* avoid conditional code as much as possible
* why revert 537? We should think about the replacement first, I believe. Or does it make the situation worse than before?

Mark
I think the idea to revert is only to avoid a rework, as before 537 the calls are already centered on one function ;)

I'm doing, yes. Soon I'll post a patch here. 10 minutes ;)
Use the FU!!!!!IN Google !

gto's Zeos Quick Start Guide

Te Amo Taís!
gto
Zeos Dev Team
Zeos Dev Team
Posts: 278
Joined: 11.11.2005, 18:35
Location: Porto Alegre / Brasil

Post by gto »

Uhm, much quicker :)

Patch created on testing folder, at Rev 537.

ZEOS_FULL_UNICODE removed from zeos.inc and all calls to it redirected to DELPHI12_UP.

UPDATE:

Already commited to Rev 538!
Last edited by gto on 08.12.2008, 15:56, edited 2 times in total.
Use the FU!!!!!IN Google !

gto's Zeos Quick Start Guide

Te Amo Taís!
gto
Zeos Dev Team
Zeos Dev Team
Posts: 278
Joined: 11.11.2005, 18:35
Location: Porto Alegre / Brasil

Post by gto »

Ahm.. sorry for trolling and triple-posting, but there's another idea: Why don't we create a table on supported DB's and their support to unicode, if any ?

I think will make things clear, and then we can plan something.

Am I right?
Use the FU!!!!!IN Google !

gto's Zeos Quick Start Guide

Te Amo Taís!
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

That's a constructive idea. (New thread!!)

Mark
Image
Locked