SETLOCALE - control locale-specific settings.

(ANSI Standard)


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


int class;
indicates which locale-specific conventions should be set. The class argument should be one of the following manifests (defined in <locale.h>:
says that the functions strcoll and strxfrm should use the collating sequence of the locale specified by locale.
says that the character-handling functions declared in <ctype.h> should use the extended character set of the locale specified by locale.
says that the function localeconv should format monetary values in the format of the locale specified by locale.
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.
says that the locale-specific formats of the strftime function should be set to those of the locale specified by locale.
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.


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


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.