Subject | Re: [firebird-support] Bug with character sets |
---|---|
Author | Milan Babuskov |
Post date | 2009-05-19T13:11:07Z |
Martijn Tonies wrote:
result from statement. In IBPP we retrieve this info via
Statement::ColumnSubType(). Apparently it is stored in XSQLVAR
structure, but I didn't dig deep into the source to find where exactly.
So, once you turn bytes into characters, you divide "buffer length" with
"bytes per char" to get the size in characters and then truncate the
string to that number of characters.
Maybe my previous example was not good. Imagine this:
select 'ABC' from rdb$database;
The result is:
Buffer: 'ABC '
Length: 12
Character set ID: 4 (UTF8)
Bytes per char: 4
Real length in characters = 12 / 4 = 3.
--
Milan Babuskov
http://www.flamerobin.org
http://www.guacosoft.com
> How is this buffer filled and how do you know what bytes are significantThe client gets the buffer, buffer length and character set ID as a
> and what bytes aren't?
result from statement. In IBPP we retrieve this info via
Statement::ColumnSubType(). Apparently it is stored in XSQLVAR
structure, but I didn't dig deep into the source to find where exactly.
So, once you turn bytes into characters, you divide "buffer length" with
"bytes per char" to get the size in characters and then truncate the
string to that number of characters.
Maybe my previous example was not good. Imagine this:
select 'ABC' from rdb$database;
The result is:
Buffer: 'ABC '
Length: 12
Character set ID: 4 (UTF8)
Bytes per char: 4
Real length in characters = 12 / 4 = 3.
--
Milan Babuskov
http://www.flamerobin.org
http://www.guacosoft.com