Subject Re: Writing UTF16 to the database
Author fxam
> I'm writing in C and have started using wchar_t strings internally, and
> wish to write the contents of these to a firebird db. However, having
> set the character set for the VARCHAR field to Unicode_fss, only the
> first character of the field is written to the field (as I guess it
> finds that the second byte in the string is zero). Is there a function I
> can use to write a wchar_t string (UTF-16) to this field?
You can use VARCHAR OCTETS to store UTF-16, OCTETS accepts everything
including nulls, but you have to try yourself whether you can retrieve back
all the null characters in the field.

I use Delphi to write UTF-16 into VARCHAR OCTETS successfully using
Interbase dbExpress driver, the problem left is how to get the data back
in full shape including nulls. I will investigate again what Helen said
about default charset and _unicode_fss.

> Alternatively, is there a way of encoding a wchar_t to a single byte
> encoding (must be able to store international data - maybe utf-8?) so
> that IT could go into firebird instead?
I tried Delphi to store and load UTF-8 successfully using Interbase
dbExpress driver. Since UTF-8 do not have null characters (except for the
null character itself), I guess you can use VARCHAR with any charset (I
used OCTETS). If your application does not support UTF-8 directly, you have
to convert the data from/to UTF-8 before making changes and after retrieving
data.