Example: Calling cs_locale to Load a CS_LOCALE structure

Suppose an application is running on a machine with a locales.dat file containing the following entries:

locale = korean, korean, eucksc, korsrt
locale = C.korean, us_english, eucksc, ussrt
locale = default, us_english, iso_1, ussrt

where the format of an entry is:

locale = locale_name, language_name, charset_name [,sort_order] 

Suppose further that the environment variable LC_MESSAGE has a value of “korean,” and that the environment variable LC_TIME is not defined. In this environment, the application would need to make two calls to cs_locale to load a CS_LOCALE structure with the following custom values:

The two cs_locale calls are:

/*
 ** You should not specify a locale name, because
 ** cs_locale will use the value of the LC_MESSAGE
 ** environment variable as the locale name.
 */
 cs_locale(ctx, CS_SET, mylocale, CS_LC_MESSAGE,
     NULL, CS_UNUSED, NULL);
 
 /* Do need to specify a locale name, because 
 ** there’s no LC_TIME environment variable set.
 */
 cs_locale(ctx, CS_SET, mylocale, CS_LC_TIME,
     "C.korean", CS_NULLTERM, NULL);

After loading the CS_LOCALE structure, the application can: