Handling Locale-Sensitive Data
An Informix database has a fixed locale per database. This locale, the database locale, is attached to the database at the time that the database is created. In any given database, all character data types (such as CHAR, NCHAR, VARCHAR, NVARCHAR, and TEXT) contain data in the code set that the database locale supports.
An opaque data type can hold character data. The following support functions provide the ability to transfer opaque-type data between a client application and the database server:
However, the ability to transfer the data between client application and database server is not sufficient to support locale-sensitive data. It does not ensure that the data is correctly manipulated at each end. You must ensure that both sides of the connection handle the locale-sensitive data, as follows:
It must also have the CLIENT_LOCALE environment variable set correctly.
In addition, the DB_LOCALE and SERVER_LOCALE environment variables must be set correctly.
For more information on the CLIENT_LOCALE, DB_LOCALE, and SERVER_LOCALE environment variables, see the Guide to GLS Functionality.
To help you write support functions to handle locale-sensitive data, Informix provides the Informix GLS API. The GLS API is a thread-safe library. This library contains C functions that allow your support functions to obtain locale-specific information from Informix GLS locales, including:
For an overview of the GLS API, see the Guide to GLS Functionality. For a description of the GLS API functions, see the GLS API Programmer's Manual. 
In Input and Output Support Functions
The LVARCHAR (and mi_lvarchar) data type can hold data in the code set of the client or database locale. This data includes single-byte (ASCII and non-ASCII) and multibyte character data. The LVARCHAR data type holds opaque-type data as it is transferred to and from the database server in its external representation. Therefore, the external representation of an opaque data type can hold single-byte or multibyte data.
However, you must write the input and output support functions to interpret the LVARCHAR data in the correct locale. These support functions might need to perform code-set conversion if the client locale and database locale support different code sets. For more information on code-set conversion, see the Guide to GLS Functionality.
In Receive and Send Support Functions
The SENDRECV (and mi_sendrecv) data type holds the internal structure of an opaque type. This internal structure can contain the following types of locale-sensitive data:
This data includes single-byte (ASCII and non-ASCII) and multibyte character data.
The client application has no way of interpreting the fields of the internal structure because an opaque type is encapsulated.
The SENDRECV data type holds opaque-type data as it is transferred to and from the database server in this internal representation. You must write the receive and send support functions to interpret the locale-specific data within the SENDRECV structure.
|