INFORMIX
Informix Guide to GLS Functionality
Chapter 1: GLS Fundamentals
Home Contents Index Master Index New Book

How Do You Set a GLS Locale?

In a client/server environment, both the database server and the client application must know which language the data is in to be able to process the application data correctly. The language affects database-server tasks such as sorting (collation) and comparison. It also affects client tasks such as end-user formats and alphabetic case conversion.

A GLS locale identifies the code set, the collation sequence, character classification (for comparisons), and end-user formats of monetary, numeric, date, and time data. For the database server and the client application to communicate successfully, you must establish the appropriate GLS locales for your environment.

This section describes the following topics:

The Default Locale

Informix products use U.S. English as the default locale. This locale specifies the following information:

To use the default locale for your Informix database applications, you do not need to perform any special steps. However, if you want to use a customized version of U.S. English, or British English, or even another language, you must set environment variables to identify the appropriate locale. For information on how to specify a GLS locale, see "A Nondefault Locale".

The Default Code Set

The default code set is the code set that the default locale supports. When you use the default locale, the default code set supports both the ASCII code set and some set of 8-bit characters. (For a chart of ASCII values, see the Relational Operator segment in the Informix Guide to SQL: Syntax.) The name of the default code set is platform dependent.

UNIX
The default code set on UNIX platforms is ISO8859-1.

Windows
The default code set for Windows environments is Microsoft 1252.

Default Date and Time End-User Formats

When you use the default locale, Informix products use the following end-user formats for date and time values:

For an introduction to date and time end-user formats, see "Date and Time Formats". For information about how to customize these end-user formats, see page 1-50.

Default Numeric and Monetary End-User Formats

When you use the default locale, Informix products use the following end-user formats for numeric and monetary values:

For monetary values, Informix products also use the currency symbol, which is the dollar sign ($) and which appears in front of a monetary value.

For an introduction to numeric and monetary end-user formats, see "Numeric and Monetary Formats". For information about how to customize these end-user formats, see page 1-53.

GLS Locale Names

A GLS locale name identifies the language, territory, and code set that you want your Informix product to use. This name has the following syntax.

code_set

is the name of the code set that the locale supports.

language

is the two-character name that represents the language for a specific locale.

modifier

is an optional locale modifier that has a maximum of four alphanumeric characters. This specification modifies the cultural-convention settings that the language and territory settings imply. The modifier usually indicates a special type of localized order that the locale supports. For example, you can set @modifier to specify dictionary or telephone-book collation order.

territory

is a two-character name that represents the cultural conventions. For example, territory might specify the Swiss version of the French, German, or Italian language.

The default locale, U.S. English, has the following locale name, where en indicates the English language, us indicates the United States territory, and code_set indicates the platform-specific name of the default code set:

UNIX
The name of the default locale on UNIX platforms is en_us.8859-1. The 8859-1 indicates the name of the default code set, the ISO8859-1 code set.

Windows
The name of the default locale for Windows environments is en_us.1252. The 1252 indicates the name of the default code set, the Microsoft 1252 code set.

In a locale name, you can specify the code set as either the code-set name or the condensed form of the code-set name. For example, the following locale names both identify the U.S. English locale with the ISO8859-1 code set:

For more information on the condensed form of a code-set name, see page A-10.

The default locale has no locale modifier. However, Informix does provide the following locale that supports dictionary sort order for U.S. English, where code_set indicates the platform-specific name of the default code set:

A sample nondefault locale for a French-Canadian locale follows:

UNIX
You can use the glfiles utility to generate a list of the GLS locales that are available on your UNIX system. For more information, see
"The glfiles Utility".

An Informix product converts the locale name into a GLS locale file. A locale file is a runtime version of the locale information. The locale name must correspond to a GLS locale file in a subdirectory of the Informix installation directory (which the INFORMIXDIR environment variable indicates) called gls. For more information on GLS locale files, see Appendix A, "Managing GLS Files."

Locales in the Client/Server Environment

When a database application runs in a client/server environment, the client application, database server, and database(s) might reside on different computers. Figure 1-1 shows a sample database server connection between an ESQL/C client application and the acctng database through an Informix database server (OnLine or Universal Server).

Figure 1-1
Example of a Client/Server Environment

These computers might have different operating systems or different language support. To ensure that these three parts of the database application communicate locale information successfully, Informix products support the following locales:

Figure 1-2 shows the client locale, database locale, and server locale that the sample ESQL/C application (from Figure 1-1) establishes.

Figure 1-2
The Client Locale, Database Locale, and Server Locale

When you set the same or compatible GLS locales for each of these locales, your client application is not dependent on how the operating system of each computer implements language-specific features.

The following sections describe each of these locales in more detail.

The Client Locale

The client locale specifies the language, territory, and code set that the client application uses to perform read and write (I/O) operations on the client computer. In a client application, I/O operations include reading a keyboard entry or a file for data to be sent to the database, and writing data that the database server retrieves from the database to the screen, a file, or a printer. In addition, an SQL API client uses the client locale for literal strings (end-user formats), embedded SQL statements, host variables, and data sent to or received from the database server with ESQL library functions in an ESQL source (.ec) file.

In the sample connection that Figure 1-2 shows, if the client locale is German with the Microsoft 1252 code set (de_de.1252), the German locale-specific information that the ESQL/C client application uses includes the following:

Tip: To provide this information for the client locale, the locale file contains the following locale categories, COLLATION, CTYPE, TIME, MONETARY, and NUMERIC. For more information, see "Locale Categories".
The database server uses the client locale as one part of the information to determine the server-processing locale for the current session. For more information, see "Establishing a Database Connection".

To determine the client locale, Informix client applications use environment variables set on the client computer. To obtain the localized order and end-user formats of the client locale, a client application uses the following precedence:

    1. DBDATE and DBTIME environment variables for the end-user formats of date and time data and DBMONEY for the end-user format of monetary data (if one of these is set)

    2. GL_DATE and GL_DATETIME environment variables for the end-user formats of date and time data (if one of these is set)

    3. The information that the client locale defines (CLIENT_LOCALE, if it is set)

    NLS
    4. LC_* environment variables for the associated category of the client locale (if DBNLS is set on the client):

    5. LANG environment variable (if, on the client, DBNLS is set, but the associated LC_* is not set)

    6. The default locale (U.S. English)

Client applications that are based on Informix Version 9.1 products use the precedence of steps 2, 3, and 6 in the preceding list. You do not need to set the other environment variables for Version 9.1 client applications. Support for DBDATE and DBTIME provides backward compatibility for client applications that are based on earlier versions of Informix products. Informix recommends that you use GL_DATE and GL_DATETIME for new applications.

NLS
Support for LANG and the LC_* environment variables provides backward compatibility for client applications that are based on Informix NLS products. These applications use the precedence of steps
, 4, 5, and 6 in the preceding list. You are not required to set CLIENT_LOCALE for NLS-based applications. However, CLIENT_LOCALE does provide certain advantages to your application. For more information, see the Informix Migration Guide.

ALS
Client applications that are based on Informix ALS products use the precedence of steps
, 3, and 6 in the preceding list. For more information about how to run ALS-based applications, see the Informix Migration Guide.

For information on the CLIENT_LOCALE, DBDATE, DBTIME, DBMONEY, GL_DATE, and GL_DATETIME environment variables, see their entries in Chapter 2, "GLS Environment Variables."

The Database Locale

The database locale specifies the language, territory, and code set that the database server needs to interpret locale-sensitive data types (NCHAR and NVARCHAR) in a particular database correctly. The database locale determines the following information for the database:

The database server uses the database locale as one part of the information to determine the server-processing locale for the current session. For more information, see "Establishing a Database Connection".

The database server also uses the database locale when it creates a new database. It stores a condensed version of the database locale in the systables catalog of the database.

NLS
Informix NLS databases (before Version 7.2) also store the locale-specific information in systables. However, the locale names are different from those in GLS databases. For information on how GLS database servers convert NLS databases, see the Informix Migration Guide.

ALS
Informix ALS databases store the locale-specification information somewhat differently. For information on how GLS database servers convert ALS databases, see the Informix Migration Guide.

When the database server stores the database locale information directly in the system catalog, it permanently attaches the locale to the database. In this way, the database server can always determine the locale that it needs to interpret the locale-sensitive data correctly. This information includes operations such as how to handle regular expressions, compare character strings, and ensure proper use of code sets.

In the sample connection shown in Figure 1-2, the database server references the database locale when the client application requests sorted information for an NCHAR column in the acctng database. If the database locale is German with the Microsoft 1252 code set (de_de.1252), the database server uses a localized order that sorts accented characters, such as ö, after their unaccented counterparts. This order means that the string öff sorts after ord but before pre.

The client application uses the database locale (as set on the client computer) to determine whether to perform code-set conversion. For more information, see "Performing Code-Set Conversion".

The Server Locale

The server locale specifies the language, territory, and code set that the database server uses to perform read and write (I/O) operations on the server computer (the computer on which the database server runs). These I/O operations include reading or writing the following files:

However, the database server does not use the server locale to write files that are in an Informix-proprietary format (database and table files). For a more detailed description of the files that the database server writes in the server locale, refer to Chapter 4, "INFORMIX-Universal Server Features," Chapter 5, "INFORMIX-OnLine Dynamic Server Features," and Chapter 6, "INFORMIX-SE Features."

In the sample connection that Figure 1-2 shows, the Informix database server uses the server locale to determine the code set to use when it writes a message-log file.

Tip: The database server is the only Informix product that needs to know the server locale. Any database server utilities that you run on the server computer use the client locale to read from and write to files and the database locale (on the server computer) to access databases that are set on the server computer.

A Nondefault Locale

By default, Informix products use the U.S. English locale. However, Informix products support many other locales. To use a nondefault locale, you must set the following locale environment variables:

    If you do not set CLIENT_LOCALE, the client locale is the default locale, U.S. English.

    If you do not set DB_LOCALE, on the client computer, the client application sets the database locale to the client locale. This default value prevents the client application from the need to perform code-set conversion.

    If you do not set SERVER_LOCALE, the server locale is the default locale, U.S. English.

To set these locale environment variables, assign them the name of a GLS locale (see page 1-20).

UNIX
You set environment variables with the appropriate shell command (such as setenv for the C shell).

For example, to set the client locale to Japanese with the SJIS character set on a UNIX system, you might enter the following command on the client computer at the shell prompt:

You can use the glfiles utility to obtain a list of GLS locales that your Informix product supports. For more information, see "The glfiles Utility".

Windows
You set environment variables in the Registry (with the SETNET32 utility) or in the InetLogin structure of an SQL API program. For more information on SETNET32, see the Installation and Configuration Guide for Microsoft Windows Environments. For more information on InetLogin, see the Microsoft Windows supplement for your SQL API documentation.

You can examine the %INFORMIXDIR%\gls\lcX directory to determine the GLS locales that your Informix product supports. For more information on this directory, see Appendix A.

When you want to access a database locale with a nondefault locale, the client and database locales on your client computer must support this nondefault locale. Make sure that these two locales are the same or that their code sets are convertible. For more information on convertible code sets, see "Performing Code-Set Conversion".

For example, to access a database with a Japanese SJIS locale, set both the DB_LOCALE and CLIENT_LOCALE environment variables to the ja_jp.sjis locale name. If you set DB_LOCALE but do not set CLIENT_LOCALE, the client application returns an error because it cannot set up code-set conversion between SJIS (the database code set) and the default code set (the code set of the default locale).

When a client application requests a connection, the database server uses information in the client, database, and server locales to create the server-processing locale. For more information, see "Establishing a Database Connection". For information on the syntax of the CLIENT_LOCALE, DB_LOCALE, and SERVER_LOCALE environment variables, refer to those entries in Chapter 2, "GLS Environment Variables."




Informix Guide to GLS Functionality, version 9.1
Copyright © 1998, Informix Software, Inc. All rights reserved.