Subject Re: UTF8, malformed string error
Author Roman Rokytskyy
Hi,

> With Delphi, I'm trying to insert characters into a UTF8 column
> in Firebird 2.
>
> If I'm trying to insert a string 'test', it works fine:
>
> (IBO)
> FCommand.Params[Index].AsString := 'test';
>
> But as soon as more special characters are used:
> FCommand.Params[Index].AsString := 'tesét';
>
> Firebird raises a "malformed string" error.
>
> I've tried WideString instead of String, but that inserts the first char
> only, so that seems way off.

You have to check IBO sources whether it supports encodings at all. In
Java we recode the characters from the internal representation (which
happens to be Unicode, but not UTF8) into the one that Firebird
expects (the lc_ctype connection property).

The WideString is not UTF-8 as well as normal Pascal and/or C/C++
strings. However, you can convert WideString into UTF-8 string and
then assign to AsString property (assuming that IBO does not perform
any conversion internally).

I have just found a library that performs that task in Delphi:
http://fundementals.sourceforge.net/unicode.html, but maybe there are
others as well.

Roman