[fpc-pascal] SqlDB vs Zeos: TDataset.FieldDefs[].Size

Graeme Geldenhuys graeme at geldenhuys.co.uk
Sat Apr 20 13:21:45 CEST 2013

On 2013-04-20 10:11, Ludo Brands wrote:
> 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

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.

 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.

Does Zeos have some other property I can use that will match the size
given via the DDL scripts? Alternatively I thought of "faking" the real
character size in the tiOPF backend, but I can't be sure what encoding
the database is in, so I don't know by what value to divide .Size with.

  - Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal

More information about the fpc-pascal mailing list