<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Graeme Geldenhuys wrote / napísal(a):
<blockquote cite="mid:51727A49.9070307@geldenhuys.co.uk" type="cite">
<pre wrap="">On 2013-04-20 10:11, Ludo Brands wrote:
</pre>
<blockquote type="cite">
<pre wrap="">TFieldDef.Size is expressed in bytes. Zeos, IIRC, assumes a conversion
from any charset to utf8 could be made. Since UTF8 is up to 4 bytes per
char, a VarChar(10) can need up to 40 bytes to be represented in the
</pre>
</blockquote>
<pre wrap=""><!---->
I assumed it has something to do with Unicode, but because I never
specified a text encoding for the database when I created it - this
confused me.
I would have imagined that there might be two "size" properties.
</pre>
</blockquote>
Yes like in case of TField, where is (for ftString):<br>
Size: max.length in characters used in f.e. DB-aware controls<br>
DataSize: max.length in bytes used f.e. for allocating buffer size in
record<br>
<br>
<blockquote cite="mid:51727A49.9070307@geldenhuys.co.uk" type="cite">
<pre wrap="">
1) .Size - which is the same value as specified in the DDL scripts
2) .DataSize - which might be larger than .Size in the case of Unicode
encoded database.
The problem I have with Zeos, is that I can't limit my text input in GUI
applications now... Normally the .Size property would have been used,
but now Zeos reports 4x the size, so all varchar(10) fields now look
like they can store 40 characters, instead of only 10.
</pre>
</blockquote>
It is known pain, that causes either:<br>
A.) you have enought long buffer, but then DB-aware MaxLength is
incorrect<br>
or<br>
B.) you have correct MaxLength, but data are truncated<br>
<br>
It leads me to thinking, that there is need for extend TFieldDef with
DataSize just like in TField<br>
(and make DataSize independent from Size ... now are they related:
DataSize:=Size+1 ... so for SBCS it can be as now and for Unicede
encodings it can be fe: DataSize:=Size*4+1;)<br>
<br>
-Laco.<br>
<br>
</body>
</html>