When the user clicks in a field, I'm displaying some information about that field, like maximum length, etc.
For that I'm using the Field.Size property, which returns the size of the buffer in bytes. Since we are using Unicode, I'm dividing it by 4. Works like a charm.
Unless - you connect to a 11.2.0 database, where Field.Size returns 1, seems it doesn't consider the code page settings.
It's not a big deal for me, my tool only shows the maximum field length completely messed up, I can live with that. Don't use outdated crap.
But... afaik Zeos is also using this property to allocate buffers? Isn't it a source of trouble if we are using 1 byte instead of 4 to allocate space for 1 character...? Or if Zeos is allocating properly, is there a way to get the bytes-per-character divider Zeos is using?
My code is simple...
Code: Select all
If field.Size > 0 Then
Case field.DataType Of
ftString, ftMemo, ftWideString, ftWideMemo: Result := Result + ', size: ' + Integer(field.Size Div 4).ToString + ' character(s)';
Else Result := Result + ', size: ' + field.Size.ToString + ' byte(s)';
End;