Environment: Linux Debian 10.7 or Windows 10 Informix server: IDS-14.10.FC5 Informix client: CSDK 4.50.FC5
With the DB in UTF-8 (DB_LOCALE = en_us.utf8) and client app in another character encoding (CLIENT_LOCALE=en_us.8859-15):
When fetching an LVARCHAR column, and binding with ifx_sqlvar_t sqltype=CLVCHARPTRTYPE, after the fetch we want to get the character string with ifx_var_getdata().
But it appears that the sequence of bytes returned by the ifx_var_getdata() function is pure UTF-8, and is not converted to ISO-8859-15 ...
Documentation says that this function returns ASCII data ... we assume that no conversion is done at all and it returns just the UTF-8 byte sequence.
The string should be converted to the charset of CLIENT_LOCALE, just as when binding with CVCHARTYPE and a self-allocated buffer. But that solution is not acceptable for LVARCHAR because we would need to allocate large buffers to cover the max LVARCHAR size!
"..The lvarchar pointer type is not equivalent to a C-language char pointer. Informix® ESQL/C maintains its own internal representation for the lvarchar pointer type. This representation is identical to the representation of a var binary host variable, except that it supports ASCII data as opposed to binary data..."
|Who would benefit from this IDEA?||Have non-UTF-8 code use UTF-8 databases and use LVARCHAR columns and avoid to allocate arbitrary large buffer|
How should it work?
The string should be converted to the charset of CLIENT_LOCALE, just as when binding with CVCHARTYPE.
|IBM's success depends on gathering feedback from customers like yourself. Aha Ideas Portal is the third party tool through which IBM Offering Managers gather feedback from customers such as yourself.|
|IBM is a global organization with business processes, management structures, technical systems and service provider networks that cross borders. As such, the information collected through Aha Ideas Portal (Customer Name, Customer Email Address) will be stored by them in the United States, and handled only as per IBM's instructions and policies. Your data (Name and Email Address) will NOT be shared with other IBM customers.|
|In order to safeguard your information in Aha, do not leave your workstation unattended while using this application, log off after using it, and print only if necessary. If you need to make a hardcopy, remember to pick up the print-out immediately, keep it under lock, and destroy it immediately when no longer needed.|
|NOTICE TO EU RESIDENTS: per EU Data Protection Policy, if you wish to remove your personal information from the IBM ideas portal, please login to the ideas portal using your previously registered information then change your email to "email@example.com" and first name to "anonymous" and last name to "anonymous". This will ensure that IBM will not send any emails to you about all idea submissions|