-
Notifications
You must be signed in to change notification settings - Fork 40
Description
Hello,
I help maintain the ODBC driver for IBM i and we have a question regarding SQLColumnAttribute getting SQL_DESC_OCTET_LENGTH when it comes to multibyte encodings.
There are many code pages on IBM i that store non-ASCII characters as single byte. When these are transferred to the client, the user may (and probably will) define the client character set as UTF-8. Because UTF-8 is a variable-width encoding from 1 to 4 bytes, the length of this conversion can't be known until the data is actually returned from a query (some characters may still be single byte, some may be 2 bytes, all the way up to 4 bytes).
The question: What should SQL_DESC_OCTET_LENGTH return in this situation? If a field is defined as CHAR(10), it may take up to 40 bytes to transfer if it is encoded using some exotic code page and converted for the client to UTF-8. Should SQL_DESC_OCTET_LENGTH return 40? That seems reasonable, but the Transfer Octet Length documentation notes for character data:
The defined or the maximum (for variable type) length of the column in bytes. This is the same value as the descriptor field SQL_DESC_OCTET_LENGTH.
With variable here not meaning variable-byte encoding, but variable field length (VARCHAR instead of CHAR). It would seem that it should also apply to variable byte encodings, but I just wanted to get some clarification.
Thanks!