[fpc-devel] TField.AsString and Databases with UTF-8 charset
Michael Van Canneyt
michael at freepascal.org
Fri Jul 24 12:55:57 CEST 2009
On Fri, 24 Jul 2009, Graeme Geldenhuys wrote:
> 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.
My databases are HUGE, and I don't think that such a query is appropriate.
>> 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:
Given that neither supports UTF-8, the documentation is not really
relevant, I'd say.
I agree that we need a solution, but I'm not convinced your solution
is correct or even desirable.
Don't forget also that for unicode, the number of characters differs
from the number of bytes. The Firebird API predates this, and so does
the Delphi TDataset implementation. Currently I think that introducing
a new field type TUTF8field or TUnicodeField is the right way to go.
This field can then take care of any conversion issues.
The other solution is to change the interbase layer so it reports a
TWideStringField instead of TField if the charset is UTF-8.
More information about the fpc-devel