Symbolic information in InterBase can be retrieved for the user as a different character encoding according to the query. InterBase supports number of encoding formats including Unicode. IBDAC components support UTF-8 Unicode (Unicode_FSS) encoding formats for data fields.
IBDAC allows to represent string data using string and WideString types. You can use TIBCConnection.Options.UseUnicode property to enable this behaviour.This property value affects fields of queries and stored procedures. TIBCConnection.Options.UseUnicode property has no influence to the parameters types of which were set manually.
Suppose that SIMPLE_TYPES table is created as:
CREATE TABLE SIMPLE_TYPES (
ID INTEGER NOT NULL,
F_CHAR CHAR(250),
F_VARCHAR VARCHAR2(300),
)
Suppose we open the following SELECT statement in a dataset
SELECT a.* FROM SIMPLE_TYPES a
If TIBCConnection.Options.UseUnicode is set to False you get the next fields list after dataset is opened:
ID: TIntegerField
F_CHAR: TStringField
F_VARCHAR: TStringField
When you set TIBCConnection.Options.UseUnicode to True the string fields type changes:
ID: TIntegerField
F_CHAR: TWideStringField
F_VARCHAR: TWideStringField
Fields of TWideStringField type hold rows in UTF-16 Unicode format. To get a value of the fields you can use TWideStringField.Value property. You can use FlatBuffers, LongString, FieldsAsString, TrimFixedChar options of TCustomIBCDataSet which are compatible with TIBCConnection.Options.UseUnicode.
To use Unicode values as parameters, previously you need to set a value of data type field to ftWideString or ftFixedWideChar for the fields of VARHAR or CHAR types accordingly. Otherwise after the execution of AsWideString or AsString operation data type field will be ftString by default.
var
WS: WideString;
begin
...
with IBCQuery1 do begin
Close;
SQL.Text:=
'SELECT * from SIMPLE_TYPES '+
'WHERE '+
' F_CHAR = :F_CHAR';
Params[0].DataType := ftFixedWideChar;
Params[0].AsWideString := WS;
Open;
...
Note that if table field has charset NONE or OCTETS, no charset conversion is provided and such fields are always fetched and stored as usual TStringField. You can set charset when creating or modifying table.
If parameter has Unicode data type value, assigning value by using AsString property converts String to WideString. And vice versa, if parameter doesn't have Unicode data type value, assigning value by AsWideString property converts WideString into String.
BLOB data type supports string data in UTF-8 Unicode encoding. You can set TIBCConnection.Options.UseUnicode property to True and get TMemoField of ftBlob blob type. BLOB must have subtype 1 (text) and Unicode_FSS charset to use this feature.