setlocale [ HP C/iX Library Reference Manual ] MPE/iX 5.0 Documentation
HP C/iX Library Reference Manual
setlocale
Controls locale-specific features of the library.
Syntax
#include <locale.h>
char *setlocale (int category, const char *locale);
Parameters
category Specifies that only a certain aspect is to be set to that
locale and the others are unchanged. This parameter can be
set to any one of the following macros (defined in
<locale.h>):
LC_COLLATE
LC_CTYPE
LC_MONETARY
LC_NUMERIC
LC_TIME
LC_ALL
locale Typically the name of a supported language. German, for
example, is a supported language.
Return Values
x A pointer to a string that defines the locale.
NULL The program's locale has not been changed. The request has
failed.
Description
The setlocale function controls locale-specific features of the library.
The string returned by setlocale must not be altered and may be
overwritten by subsequent calls to setlocale().
Following is a description of the behavior of setlocale() under four
different conditions:
* When in Program Startup
When a program is started, the locale of the program is the
default, C-locale.
* When Locale is Specified
If locale is specified, the named category is set to that
locale.
setlocale (LC_ALL, "german");
* When Locale is Not Specified
If locale is not specified (an empty string is used), as in
the following example,
setlocale (category,"")
the locale is set according to the following scheme:
1. If an equivalent 'LC_' environment variable is set,
the language is set to the language specified by the
variable.
2. If the environment variable LANG is set, the
language is set as specified by LANG.
3. If the JCW NLUSERLANG or NLDATALANG is set:
For LC_COLLATE and LC_TYPE, the language is
set as specified by NLDATALANG.
For LC_TIME, LC_MONETARY and LC_NUMERIC, the
language is set as specified by NLUSERLANG.
Otherwise, locale is set to be the C-locale.
* When Locale is Null
If the locale is a null pointer, the setlocale function
returns the current locale of the named category to the
program. For example,
setlocale (LC_MONETARY,NULL);
returns to the program the locale that is set for monetary
processing. This is a query operation that does not change
the locale environment of the program.
NOTE The default locale is always the C-locale.
See Also
localeconv(), ANSI C 4.4.1.1, POSIX.1 8.1.2
MPE/iX 5.0 Documentation