Subject Unicode utf-8 Widestring - does not work as expected
Author Maik Wojcieszak
I'm using IBObjects 4.9.11 with an UTF8 charset in a Firebird database.
There are problems storing and reading strings with Delphi 2010 (Unicode strings).
In the Fields there are functions/properties called "AsString" (AnsiString) and "AsWideString" (WideString).
Both functions don't work properly with the new Delphi Unicode strings.
Chinese chars doesn't pass this functions properly, storage as UTF8 in Database doesn't work fine.
I took a look in the IB_Components.pas unit and wonder about the string handling there.
In line 44810 for example is a call to "UTF8Decode", which returns a WideString, but it will be forced afterwards to AnsiString!
That's not good. There should be a WideString type of GetAsString returning the direct output of "UTF8Decode".
The functions "Get-/SetAsWideString" sound like the desired functionality, but they hasn't a correct string handling
and I think they cannot be touched because of downward compatibility.

The existing "Get-/SetAsString" functions should be renamed to "Get-/SetAsAnsiString" and
the Unicode versions should be the new "Get-/SetAsString".

Maybe like this: (functions are simplified)

function TIB_Column(Var)Text.GetAsString: string;
begin
if FNewColumnInd^ = IB_NULL then
Result := ''
else
begin
if Statement.IB_Connection.CharSet = IBO_UTF8 then
Result := UTF8ToString(Value) // deprecated: UTF8Decode(Value)
else
...
end;
end;

procedure TIB_Column(Var)Text.SetAsString(const NewValue: string);
begin
if Statement.IB_Connection.CharSet = IBO_UTF8 then
Value := UTF8Encode(NewValue)
else
...
end;

Any idea - somebody ?
Regards,
Maik



[Non-text portions of this message have been removed]