Sets, queries, or restores a portion of a program’s locale.
#include <locale.h>
char *setlocale (
int category,
const char *locale);
(IN) Specifies the environment category for the specified locale.
(IN) Points to the locale for the program. Pass a NULL pointer to query the current locale for the information specified by the category parameter.
If successful, returns the string associated with the specified category for the new locale. Otherwise, returns a NULL pointer.
The setlocale function selects a portion of a locale for a program according to the category given by the category parameter and the locale specified by the locale parameter.
A locale might affect the collating sequence (the order in which characters compare with one another), the way in which certain character-handling functions operate, the decimal-point character that is used in formatted input/output and string conversion, and the format and names used in the time string produced by the strftime function.
At the start of a program, the equivalent of
setlocale (LC_ALL, "C");
is executed.
NOTE:For a reentrant version of this function, see setlocale_r.
The semantics of the setlocale function can be confusing because this function is able both to query and to set aspects of the invoking process’ locale.
To query the locale setting, pass NULL for the locale parameter. When category is LC_ALL, the return is the name of the locale definition currently in force ("C", "en-us", "fr-fr", "cn-cn", etc.).
However, if category is one of the other possible values, this function returns a pointer to a string containing the currently associated definitions for the category. The expression of these definitions is not portable (nor do ISO/IEC or ANSI require that it be). Such a string can be carefully copied and modified for use in changing the behavior of a locale. The string must be copied because setlocale is not thread safe and a subsequent call by this or another thread can change the contents of the string referenced by the returned pointer.
If the category parameter is set to LC_MONETARY, LC_NUMERIC, or LC_TIME, the locale parameter must be set to NULL. This type of query returns the associated string for the current locale. In this type of query, the function cannot be used to specify both a category and a locale. If the current locale is en-us and you want to access the LC_MONETARY string for the fr-fr locale, you must first set the locale to fr-fr and then query for the string.
If the locale argument is a pointer to a character string containing correct definitions for items of category, those items will be modified in the current locale. This operation changes the locale for all threads of a process (or virtual machine), but not for any other process running on the NetWare® server. For an example of how this works, please see the example below.
In the case where category is LC_ALL, only the following strings are valid for the locale parameter:
"POSIX". Specifies the minimal environment for C-language translation called the POSIX locale. Each NLM™ starting up is set to the POSIX locale when main() is invoked.
"C". Is the ANSI/ISO name of the default locale (also known as "POSIX".) "C", "en-us", and "POSIX" are one and the same.
A valid locale name. Specifies a locale, such as "fr-fr" or "en-us". The list of valid locale names is in flux. In the nls directory on the NetWare boot partition (c:\nwserver\nls), a set of table files with the .xml extension establish what is valid. The format of the string is a two letter language code, followed by a dash, followed by a two letter country code. These .xml files are also included in the LibC SDK download and, in a default installation, are placed in the c:\novell\ndk\libc\tables directory.
NULL. Directs setlocale to query the current internationalized environment and returns the name of the locale in force.