[fpc-devel] TField.AsString and Databases with UTF-8 charset

Graeme Geldenhuys graemeg at opensoft.homeip.net
Fri Jul 24 12:39:05 CEST 2009


Michael Van Canneyt wrote:
> 
> This is not feasable, because it works only for actual fields.
> Expressions for instance will not work,

I have not tried expressions yet, but will give it a try and see what
Firebird actually does. No point in assuming or guessing. ;-)


> and secondly, it requires a second query per executed query, which is
> simply unacceptable from a performance point of view. 

No, not a second query, just keeping track of extra (other) meta data 
information which was retrieved from the first API call to Firebird.


> Firebird reports the theoretical length of each field in the result
> set, we should use that in all cases.

In that case, TField and TParam is NOT Delphi compatible.

 From the Kylix 3 and Delphi 7 documentation:

=============================
TField.Size
-----------
Returns various sizes based on data type.

ftString    Size is the maximum number of characters in the string.
...
=============================

TParam.Size
-----------
Specifies the number of characters in a string-type parameter.
=============================


In both cases, Size is the number of "characters" in the string, NOT the 
size in bytes as the current SqlDB - Firebird implementation is doing.

So Char(2) should return Size = 2. Irrespective if the character set in 
the database is ASCII or UTF8 etc... So SqlDB should be using the 
"f.rdb$character_length" field and *not* the "f.rdb$field_length" for 
string types.



Regards,
   - Graeme -

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://opensoft.homeip.net/fpgui/




More information about the fpc-devel mailing list