Syntax
#include <locale.h> char * querylocaleenv (void)Description
querylocaleenv searches the process environment to resolve the locale object category values according to the following priority:
The LANG environment variable has the lowest priority of all the environment variables used by querylocaleenv to initialize locale categories.
The following actions occur in the absence of the environment variables:
querylocaleenv returns a pointer to a NULL terminated char string that represents the result of the search of the locale environment variables. The pointer points at memory that has been allocated by calling malloc. You can choose to return this memory by calling the free function.
The format of the returned category string is a NULL terminated set of 7-bit ASCII encoded characters. The returned string contains the values of the following environment variables listed in the order that they are returned in the string:
LC_COLLATE LC_CTYPE
LC_MONETARY
LC_NUMERIC
LC_TIME
LC_MESSAGES
The value of the environment variables is a string with the following format made up of the name of the locale that is currently selected:
language_territory
where language is the ISO 639 two-letter name and territory is the ISO 3166 two-letter territory (country) name. For example, fr_FR represents French in France. Example Code
#include <unidef.h> #include <locale.h> /* -------------------------------------------------------------- */ /* Pointer to contents of locale environment variables */ /* -------------------------------------------------------------- */ char *pEnv; int rc; LocaleObject locale_object; /* -------------------------------------------------------------- */ /* Test pointer returned from querylocaleenv call */ /* -------------------------------------------------------------- */ if ((pEnv=querylocalenv)==NULL) { /* -------------------------------------------------------------- */ /* Error indicating out-of-memory */ /* -------------------------------------------------------------- */ } else { rc=UniCreateLocaleObject(UNI_MBS_STRING_POINTER,pEnv, &locale_object); /* -------------------------------------------------------------- */ /* locale_object can be used in subsequent calls to ULS APIs */ /* -------------------------------------------------------------- */ free(pEnv); }Related Information