Subject Re: [IBO] How to get Delphi + IBObjects to read/write in unicode to Firebird 1.5
Author Helen Borrie
At 02:02 PM 3/11/2005 +0000, you wrote:
>Hi all,
>New to developing with Firebird using IBObjects and Delphi - used to
>developing with ADO and SQL Server with Delphi.
>I'm trying to develop a system that will read and write in Unicode with
>FB, IBO and Delphi. I am using the TnT Controls for the visual display
>and they can show unicode characters fine but I am a little stuck as to
>how to read and write using IBO tables, queries and stored sprocs in
>unicode and what format fields need to be in in FB to store the info
>Anyone managed to achieve this yet ok?

Hmmm, I can't solve you problems, only share some experiences. I've
fiddled with it; though I lack a source of Unicode data, that always clues
up with me getting stuck on testing characters beyond the 7-bit range.

As long as you are in the process of trying out stuff, make sure that both
the default character set of the database AND the character set of the
connection are UNICODE_FSS. The decisions that the server makes about the
charset of the incoming data are dependent on the client "knowing" what
kind of data it is passing.

In Fb 1.5, there's a bit of leeway if you hit a database or column that's
defined for unicode_fss with client data that is charset NONE, but I
haven't tested it myself. As far as I can work out, this can simplify
things only in the case where there's a mismatch between the character set
of the data and a defined default charset. It might not work where the
default charset of the DB is one charset while the defined charset of the
specific column is different.

Anyway, you don't say which Firebird you're using.

I don't (so far) know of any magic bullet that you can fire into your app
that works for both reading and writing. If everything matches up and you
have components that know how to display and interpret UNICODE_FSS, then
selects and displays with the TIBODatasets should be OK. If the controls
are doing their job, they should be updating the dataset properly.

It's when you come to read variables into parameters that things get a bit
queasy sometimes. Delphi's widestring stuff doesn't cater for MBCS wider
than 2 bytes; unicode_fss is a fixed 3 bytes for every glyph, even the
7-bit set.

I seem to recall in my experiments with the Tnt controls that reading
values from the dataset's Fields[] array AsRawString directly into
Params[n].Value is fine; but you may need custom xxxxSQL properties that
contain the introducer syntax, to get user inputs into parameter values.

There are also issues like whether the font being used in controls is one
that supports Unicode (not many do!) and (maybe) OEM codepage issues (the
codepage being the set of glyphs that the OS associates with specific
character codes from input devices and to output devices).

Not much help, I know. It's been in my mind for a long time to do a TI
sheet on handling MBCS in IBO apps. I hope someone who is doing it "for
real" will step up and advise you (Daniel Rail?) and we can assemble enough
to do a demo app...but it won't be now, since I'm flat out with 3 lots of
release notes and the organisation details of the Fb conference and too
short on sleep to concentrate on yet another thing.