SETLOCALE - control locale-specific settings.

(ANSI Standard)

Usage:

#include <locale.h>
char *setlocale(int class,const char *locale);

Where:

int class;
indicates which locale-specific conventions should be set. The class argument should be one of the following manifests (defined in <locale.h>:
LC_COLLATE
says that the functions strcoll and strxfrm should use the collating sequence of the locale specified by locale.
LC_CTYPE
says that the character-handling functions declared in <ctype.h> should use the extended character set of the locale specified by locale.
LC_MONETARY
says that the function localeconv should format monetary values in the format of the locale specified by locale.
LC_NUMERIC
says that the decimal point character and other nonmonetary numeric conventions should be those of the locale specified by locale. This affects localeconv and all the functions that read or write formatted floating point numbers.
LC_TIME
says that the locale-specific formats of the strftime function should be set to those of the locale specified by locale.
LC_ALL
says that all of the above locale-specific features should be set to those of the locale specified by locale.
const char *locale;
is a string specifying a locale supported by the current implementation. All implementations will support the "C" locale. If locale points to a null string, setlocale will use the conventions of the implementation's "native" environment; these conventions are implementation-defined. The locale value may also be a null pointer, as described below.

Description:

The setlocale function tells library functions to behave according to the conventions of a particular locale. As shown above, setlocale may only set up some of the conventions of a locale, and leave the others as they were. All C programs behave as if

setlocale(LC_ALL,"C");

is executed during program start-up.

If the locale argument is a null pointer, setlocale returns a pointer to a string which identifies the locale currently associated with the given class of conventions. In this case, the conventions of the class are not changed.

If the locale pointer is not null, setlocale tries to set the locale conventions as requested. If this fails, setlocale returns a null pointer. Otherwise, setlocale returns a string giving the new locale setting for the given class. This string can be used in a subsequent call to setlocale (with the same class value) to restore that part of the program's locale. A new call to setlocale may overwrite the contents of the string returned by the previous call to setlocale.

See Also:

expl nsc lib localeconv

Copyright © 1996, Thinkage Ltd.