[Lazarus] TDBEdit, TStringField Size, DataSize, DisplayWidth and MaxLength
Tony Whyman
tony.whyman at mccallumwhyman.com
Wed Oct 12 15:02:01 CEST 2016
On 11/10/16 19:21, LacaK via Lazarus wrote:
> I am aware of it. I have not added all other MBCS because ! I doubt,
> which are realy used nowadays.
> My guess is that UTF-8 is far most used / supported as client
> character set.
> No problem to add them if there will be real demand from users ...
Perhaps the correct answer is to let the database driver work this one
out rather than have a fixed decision in the FCL.
I would suggest the following change:
function TStringField.GetDataSize: Integer;
begin
Result := FieldDef.CharSize * Size + 1;
// case FCodePage of
// CP_UTF8: Result := 4*Size+1;
// else Result := Size+1;
// end;
end;
TFieldDef.GetCharSize uses the same algorithm so this avoids a code
duplication anyway. But I also want to make TFieldDef.GetCharSize and
TFieldDef.CreateField virtual methods. That way a database driver can
readily expand upon the character sets supported to match what it
supports rather than be limited by the FCL default.
In IBX, I have already done this using TIBFieldDef and TIBStringField as
subclasses in order to pass character set information. However, because
TFieldDef.CreateField is non-virtual, the implementation is not as
elegant as it should be. That is the extra info is added to the
TIBStringField as the dataset is opened rather than when the field is
created. It is also less maintainable as the functionality should be in
TIBFieldDef rather than in a different class altogether.
Making those two methods virtual is the most important change. I can
live with TStringField.GetDataSize as it is because that is already
virtual and a future TIBStringField can readily override it.
Tony Whyman
MWA
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20161012/9f0f0f71/attachment.html>
More information about the Lazarus
mailing list