The functions related to system locales are as follows:
Set the program locale
Query installed locales
Free memory associated with a localelist() call
The localelist() function is used to query the locales which are installed on a system. For information about how to install additional locales on an Oracle Solaris system, see International Language Environments Guide for Oracle Solaris 11.2 .
For more information, see the setlocale(3C), localelist(3C), localelistfree(3C), locale_alias(5), langinfo.h(3HEAD), nl_types.h(3HEAD), and environ(5) man pages.
Example 2-1 Setting the Locale of a ProgramThe following code fragment shows how to set the locale to en_US.UTF-8.
#include <locale.h> : (void) setlocale(LC_ALL, "en_US.UTF-8");
The following code fragment shows how to query the current locale.
#include <locale.h> : char *locale; : locale = setlocale(LC_ALL, NULL);
In this example, the locale variable is set to the current locale of the program.
Example 2-3 Using the Locale Settings From the User EnvironmentThe following code fragment shows how to set the env_locale variable to use the locale settings from the user environment.
#include <locale.h> : char *env_locale; env_locale = setlocale(LC_ALL, "");
For example, if the locale in the user environment is es_ES.UTF-8, the env_locale variable is set to es_ES.UTF-8.
"/es_ES.UTF-8/es_ES.UTF-8/es_ES.UTF-8/es_ES.UTF-8/es_ES.UTF-8/de_DE.UTF-8"
This string includes the categories LC_CTYPE, LC_NUMERIC, LC_TIME, LC_COLLATE, LC_MONETARY, and LC_MESSAGES, where LC_MESSAGES was set in the environment to de_DE.UTF-8.