Subject | Re: [firebird-support] Bug with character sets |
---|---|
Author | Martijn Tonies |
Post date | 2009-05-19T13:21:17Z |
Hello Milan,
like:
ASCII 'A' - 1 byte
'<somechar>' - 2 bytes
ASCII 'C' - 1 byte
<8 spaces>
And when decoding this to a string in the client app, the decode routine
recognizes multi-byte chars and decodes them accordingly?
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
>> How is this buffer filled and how do you know what bytes are significantAnd what if one of the characters is multi-byte? You get something
>> and what bytes aren't?
>
> The client gets the buffer, buffer length and character set ID as a
> 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.
like:
ASCII 'A' - 1 byte
'<somechar>' - 2 bytes
ASCII 'C' - 1 byte
<8 spaces>
And when decoding this to a string in the client app, the decode routine
recognizes multi-byte chars and decodes them accordingly?
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