Using initial localization values

A typical internationalized Open Client and Open Server application uses the initial localization values determined by LC_ALL, LANG, or the “default” entry in the locales.dat file to localize.

Initial localization values are determined at runtime, when the Open Client and Open Server application calls the CS-Library routine cs_ctx_alloc to allocate a CS_CONTEXT structure. When an application makes this call, CS-Library loads initial localization information into the new context structure.

The localization information includes:

The loading process works as follows:

  1. The application calls cs_ctx_alloc.

  2. CS-Library searches the environment for the LC_ALL or LANG environment variables to determine a locale name. Table 2-1 describes this search:

    Table 2-1: How CS-Library determines a locale name

    Is LC_ALL defined?

    Is LANG defined?

    CS-Library action

    Yes

    N/A

    Use LC_ALL’s value as the locale name.

    No

    Yes

    Use LANG’s value as the locale name.

    No

    No

    Use a locale name of “default,” which means CS-Library loads one of the following:

    • The shipped defaults for the platform

    • The user-defined set assigned to the locale name “default”

  3. CS-Library looks up the locale name in the locales.dat file to determine the associated language and character set (a collating sequence may or may not be specified). If the locale name does not exist in the locales.dat file, cs_ctx_alloc returns an error.

  4. CS-Library loads the new context structure with the appropriate localization information.