informix
Informix Guide to GLS Functionality
General SQL API Features

Supporting GLS in Informix Client Applications

To connect to a database, an ESQL/C client application requests a connection from the database server. The database server must verify that it can access the database and establish the connection between the client and the database. Your client application performs the following tasks:

Client Application Code-Set Conversion

This section summarizes the code-set conversion that a client product performs. For more general information about code-set conversion, see Performing Code-Set Conversion.

An Informix client application automatically performs code-set conversion between the client and database code sets when the following conditions are true:

When the client application begins execution, it compares the names of the client and database locales to determine whether to perform code-set conversion. If the CLIENT_LOCALE and DB_LOCALE environment variables are set, the client application uses these locale names to determine the client and database code sets, respectively. If CLIENT_LOCALE is not set (and DBNLS is not set), the client application assumes that the client locale is the default locale. If DB_LOCALE is not set (and DBNLS is not set), the client application assumes that the database locale is the same as the client locale (the value of CLIENT_LOCALE).

If the client and database code sets are the same, no code-set conversion is needed. However, if the code sets do not match, the client application must determine whether the two code sets are convertible. Two code sets are convertible if the client can locate the associated code-set-conversion files. These code-set-conversion files must exist on the client computer.

On UNIX, you can use the glfiles utility to obtain a list of code-set conversions that your Informix product supports. For more information, see The glfiles Utility. On Windows NT, you can examine the directory %INFORMIXDIR%\gls\cvY to determine the GLS code-set conversions that your Informix product supports. For more information on this directory, see Code-Set-Conversion Files.

If no code-set-conversion files exist, the client application generates a run-time error when it starts up to indicate that the code sets are incompatible. If these code-set-conversion files exist, the client application automatically performs code-set conversion when it sends data to or receives data from the database server.

When a client application performs code-set conversion, it makes the following assumptions:

For example, suppose your client application has CLIENT_LOCALE set to en_us.1252 and DB_LOCALE set to en_us.8859-1. The client application determines that it must perform code-set conversion between the Windows Code Page 1252 (in the client locale) and the ISO8859-1 code set (in the database locale). The client application then opens a database with the French fr_fr.8859-1 locale. The database server sets the eighth character field of the SQLWARN array to W because the languages and territories of the two locales are different. The database server then uses the locale of the database (fr_fr.8859-1) for the localized order of the data

However, your application might choose to use this connection. It might be acceptable for the application to receive the NCHAR and NVARCHAR data that is sorted in a French localized order. Any code-set conversion that the client application performs is still valid because both database locales support the ISO8859-1 code set. For more information about code-set conversion, see Performing Code-Set Conversion.

Instead, if the application opens a database with the Japanese SJIS (ja_jp.sjis) locale, the database server sets the SQLWARN warning flag because the language, territory, and code sets differ. The database server then uses the ja_jp.sjis locale for the localized order of the data. Your application would probably not continue with this connection. When the client application started, it determined that code-set conversion was required between the Windows Code Page 1252 and ISO8859-1 code set. The client application performs this code-set conversion until it terminates. When you open a database with ja_jp.sjis, the client application would perform code-set conversion incorrectly because the code sets are different. It would continue to convert between Windows Code Page 1252 and ISO8859-1 instead of between Windows Code Page 1252 and Japanese SJIS. This situation could lead to corruption of data.

Data That a Client Application Converts

When the code sets of two locales differ, an Informix client product must use code-set conversion to prevent data corruption of character data. Code-set conversion converts the following types of character data:


Informix Guide to GLS Functionality, Version 9.2
Copyright © 1999, Informix Software, Inc. All rights reserved