Subject Re: [firebird-support] Bug with character sets
Author Milan Babuskov
Mark Rotteveel wrote:
> Example:
> buffer length of 4 bytes, UTF-8 (max 4 bytes per character):
> is this 1, 2, 3 or 4 characters?

If it is CHAR column, it has to be 1 character.

> You simply don't know until you decode.

If it is a CHAR column (and not VARCHAR) you know that all values have
the same length in characters. By dividing the buffer size with max
bytes per character, you get how much is that. So, for CHAR columns, you
DO know before you decode because each value in a CHAR column has the
same length (padded with spaces to fit).

Decoding is only needed to turn bytes into characters, so you can use
the length to truncate the string to the correct space padding.

--
Milan Babuskov
http://www.flamerobin.org
http://www.guacosoft.com