Subject | Re: [firebird-support] Bug with character sets |
---|---|
Author | Milan Babuskov |
Post date | 2009-05-20T12:47:42Z |
Mark Rotteveel wrote:
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
> Example:If it is CHAR column, it has to be 1 character.
> buffer length of 4 bytes, UTF-8 (max 4 bytes per character):
> is this 1, 2, 3 or 4 characters?
> 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