-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
Hi Guys, I have Uploaded a new modified version. this make a lot changes to
the sources. mainly for the puprose to add full unicode support of TXQuery, at
least for Unicode IDEs (2009 an up).
I have a added full support for Unicode in TXQuery, now you can also add
unicode chars to the SQL script, an the parse will manage it gracefully.
so you can add something like:
SELECT field1, field2, field3, ('รหัสสินค้า'+' =>
'+field3) as UnicodeField3
FROM
table1
WHERE field3 = 'ěščřžýáíé';
--------------------------------------------------------------------
--NOTES Regarging NON Unicoe IDEs:
I have also made a lot of changes to add uniode support to NON Unicode IDES
(delphi 2007 and older) via the use WideStrings. I cannot validate this changes
because for now I don't have an IDE installed for those compilers.
Please feel free to test them, they should work.
In the x_flag.inc there is a compiler definition
{.$DEFINE XQ_USE_WIDESTRINGS}
This is for the NON unicode compilers, Please enable it by removing the '.',
This will force the compiler to use WideStrings instead of AnsiStrings.
When this define is disabled, the widestrings are still managed but only via
the data contained in the fields, the SQL script will be ANSI so, you cannot
put Unicode Chars in the SQL script, But any Unicode data contained in your
Datasets should be managed correctly.
I have fully tested this in Delphi XE, and should work correctly in Unicode
compilers (D2009 and up).
Some TXQuery Events would change if you force the use of WideStrings, so I
recommend to do the corrections, By default Those AnsiString Fields will be
changed to WideString and the TStringList will be changed to TWideStringList.
The changes were made to these events:
OnUDFCheckEvent
OnUDFSolveEvent
OnIndexNeededForEvent
OnSetRangeEvent
OnSetFilterEvent
OnCreateIndexEvent
OnDropTableEvent
OnDropIndexEvent
OnSyntaxErrorEvent
OnResolveDatasetEvent
OnQueryFieldNameEvent
OnSetUserRangeEvent
If you use in your code one or more of these events, You will have to copy the
code you PUT there, Remove the event and recreate it, then Paste again the code
you used in that event. This change have to be done only when you FORCE the use
of WideStrings with Delphi 2007 and older compilers.
For further changes you can ADD a compiler condition in the method definition
of the event, so it wont be affected when you migrate to a newer IDE (Unicode)
or remove the forced use of WideStrings,
Example:
procedure XQuery1ResolveDataset(Sender: TObject;
const Filename: {$IFDEF XQ_USE_WIDESTRINGS}WideString{$ELSE}String{$ENDIF};
var ATableName: {$IFDEF XQ_USE_WIDESTRINGS}WideString{$ELSE}String{$ENDIF};
var Dataset: TDataSet);
procedure XQuery1CreateIndex(Sender: TObject; Unique, Descending: Boolean;
const TableName,
IndexName: {$IFDEF XQ_USE_WIDESTRINGS}WideString{$ELSE}String{$ENDIF};
ColumnExprList: {$IFDEF XQ_USE_WIDESTRINGS}TWideStringList{$ELSE}TStringList{$ENDIF});
procedure XQuery1IndexNeededFor(Sender: TObject; DataSet: TDataSet;
const FieldNames: {$IFDEF XQ_USE_WIDESTRINGS}WideString{$ELSE}String{$ENDIF}; ActivateIndex, IsJoining: Boolean;
var Accept: Boolean);
Don't forget to Include the 'XQ_Flag.inc' file at the begining of your .pas
form unit and in any unit where you use the XQ_USE_WIDESTRINGS definition, so
the compiler definition can be evaluated correctly
This will make you code adaptable to any Delphi version.
REMEMBER This is only needed when working with delphi 2007 and older compilers
-------------------------------------------------------------------
Regards and have fun
Original issue reported on code.google.com by fdue...@gmail.com on 16 Apr 2013 at 3:07
Attachments: