<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
On 11/10/16 19:21, LacaK via Lazarus wrote:<br>
<blockquote cite="mid:web-6388810@cgp-back-6.mail.zoznam.sk"
type="cite">
<div><lazarus@lists.lazarus-ide.org>I am aware of it. I have not
added all other MBCS because ! I doubt, which are realy used
nowadays.<br>
My guess is that UTF-8 is far most used / supported as client
character set.</lazarus@lists.lazarus-ide.org></div>
<div><lazarus@lists.lazarus-ide.org>No problem to add them if
there will be real demand from users ...</lazarus@lists.lazarus-ide.org></div>
</blockquote>
Perhaps the correct answer is to let the database driver work this
one out rather than have a fixed decision in the FCL.<br>
<br>
I would suggest the following change:<br>
<br>
function TStringField.GetDataSize: Integer;<br>
<br>
begin<br>
Result := FieldDef.CharSize * Size + 1;<br>
// case FCodePage of<br>
// CP_UTF8: Result := 4*Size+1;<br>
// else Result := Size+1;<br>
// end;<br>
end;<br>
<br>
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.<br>
<br>
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.<br>
<br>
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.<br>
<br>
Tony Whyman<br>
MWA<br>
</body>
</html>