Suppose an application is running on a machine with a locales 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 form 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:
“korean” as the language and “eucksc” as the character set for Client-Library and server messages
“us_english” as the language and “eucksc” as the character set to use for conversion of datetime 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, the application can:
Call cs_config to copy the custom localization values into a context structure.
Call ct_con_props to copy the custom localization values into a connection structure.
Call srv_thread_props to copy the custom localization values into a thread structure.
Supply the CS_LOCALE structure as a parameter to a routine that accepts custom localization values (cs_strcmp, cs_time).
Include the CS_LOCALE in a CS_DATAFMT structure describing a source or destination program variable (cs_convert, ct_bind).