Subject Re: How to use Unicode with Firebird???
Author elite705
--- In firebird-support@yahoogroups.com, "kurei_spin"
<kurei_spin@y...> wrote:
> Hi! I'm having a little problem trying to use Unicode on Firebird
> 1.5.
Hi!

I have succesfully stored and received Russian Characters in Firebird
in a UNICODE_FSS Column. I used following components:

TNTControls: tntEdit
IBObjects: IBConnection+IBCursor
The unicode Unit from Delphi Fundamental
http://fundementals.sourceforge.net/unicode.html

The charset in the IBConnection Component is UNICODE_FSS.
For writing Unicode to Firebird:

with IB_Cursor1 do
begin
paramByName('UnicodeText').AsString :=
WideStringToUTF8String(tntEdit1.Text);
execute;
end;

The SQL is:

INSERT INTO Test(UnicodeText)
VALUES(:UnicodeText)

Reading Unicode from Firebird:

tntEdit1.Text :=
UTF8StringToWideString(fieldByName('UnicodeText').AsString)

I am not sure about the following, because I am relativ new to the
Unicode-Delphi-Firebird Problem. I have not tested it, except sending
a few russian characters to and from Firebird.
The problem with TNTEdit and Firebird is, that TNTEdit uses the
Windows (Delphi?) Unitcode (2 Bytes), Firebird uses 3 Bytes UTF8 or
something very similar.
So you have to Convert from Windows Unicode to Firebird Unicode with
WideStringToUTF8String und the other way with UTF8StringToWideString.
There seems to be some limitations, because 3 Bytes can store more
than two Bytes. But this only means that Firebird can for sure handle
everything that TNTEdit can handle (I hope so :-)). There may be some
Characters that TNTEdit can't handle.
Please report how the solution is working for your japanese
characters. In the moment I need only support for russian, but in the
future this may be extended. So I would like to know, if there are
some problems with this.