Subject Re: [firebird-support] Bug with character sets
Author Martijn Tonies
Hello Ann,

>>>> 1. What does Milan's code know that fbclient doesn't?
>>> Length of string in characters.
>>
>> I understand that Milan derives that from 1) buffer size and 2) max
>> number of bytes per character for the encoding used. The latter is
>> deduced from a charset id. Where does he get that charset id?
>
> That's passed in the sqlda, probably (from feeble memory) in the
> area reserved for precision of numbers. Milan's message said:
>
> select 'Y' from rdb$database;
>
> returned buffer: 'Y ';
> returned length: 4
> returned charset ID: 4 (UTF8)
>
> select RDB$BYTES_PER_CHARACTER
> from RDB$CHARACTER_SETS
> where RDB$CHARACTER_SET_ID = 4;
>
> real length in characters = 4/4 = 1
> truncate the result to 1 character to get 'Y'
>
> In FlameRobin we read in all the character set lengths
> when connecting to the database, and later just reuse that info.
>
> That procedure will, I think, preserve stored trailing spaces
> in CHAR fields - whether that's good or not is an open question.

One could wonder if knowing the bytes_per_character is something
that needs to be fetched on the client side OR if this could be passed
on by the server, so that decoding the client side structure would not
require any more knowledge than passed by the server.

With regards,

Martijn Tonies
Upscene Productions
http://www.upscene.com

Download Database Workbench for Oracle, MS SQL Server, Sybase SQL
Anywhere, MySQL, InterBase, NexusDB and Firebird!

Database questions? Check the forum:
http://www.databasedevelopmentforum.com