Subject Re: [firebird-support] Re: UTF8, malformed string error
Author Martijn Tonies
>> 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.

Well, explicitly calling an "long string to UTF8 string" works, the strings
get inserted.

Reading them fails and gets you wrong charactersets, IBO doesn't seem
to support all that UTF8 stuff.

What does Firebird expect here? Should clients transform the server
side chars to something at the client? I guess, when they request it
from the server with UTF8, it retursn them as such. I just connected
with ISO8859_1 and now the strings are returned correctly, so that
would be a server side translation, correct?


Either way -- there's another problem.

How do I know when to call these, given the generic nature of this
application?

All I know is "string" or "widestring" in Delphi, nothing about encodings.


Martijn Tonies
Database Workbench - tool for InterBase, Firebird, MySQL, NexusDB, Oracle &
MS SQL Server
Upscene Productions
http://www.upscene.com
My thoughts:
http://blog.upscene.com/martijn/
Database development questions? Check the forum!
http://www.databasedevelopmentforum.com