Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

setlocale - set or query locale

&pagelevel(4)&pagelevel

Syntax

#include <locale.h>

char *setlocale(int category, const char *locale);

Description

setlocale() can be used to change a part of the locale, as specified by category and locale, or to change or query the entire current locale or portions thereof. The following constant names, which are assigned to a database, may be specified for category:

LC_ALL

affects the entire locale (see section “Locale”).

BS2000
The locale component LC_MESSAGES is not supported for BS2000 functionality (see section “Scope of the supported C library”).
(End)

LC_COLLATE

affects the behavior of regular expressions and of string collation functions.

LC_CTYPE

affects the behavior of regular expressions, character-handling functions, and wide-character (multi-byte) functions.

LC_MESSAGES

affects the format of message strings.

BS2000
This component of the locale is not supported for BS2000 functionality (see section  “Scope of the supported C library” ). (End )

LC_MONETARY

affects the monetary formatting information returned by localeconv().

LC_NUMERIC

affects the radix character for formatted input/output functions, string conversion functions, and of the non-monetary formatting information returned by localeconv().

LC_TIME

affects the behavior of time conversion functions.

The behavior of nl_langinfo() is also affected by the settings for category.

locale is a pointer to a character string containing the required settings for category. In addition, the following preset values are defined for all settings of category:

"POSIX"

specifies the minimal environment for the programming language C; this is called the POSIX locale. If setlocale() is not invoked, the POSIX locale is the default.

"C"

same as "POSIX", but called the C locale.

""

specifies a language-dependent environment, which corresponds to the environment variables LC_* and LANG associated with the value of category.

Null pointer

is used to instruct the setlocale() function to query the current locale and to return its name.

If threads are used, then the function affects the process or a thread in the following manner: If the process is multithreaded, then the change to the locale affects all threads of the process.

BS2000

"V1CTYPE"

In contrast to the C locale, the characters X’8B’, X’8C’, X’8D’ are treated as lowercase letters, the characters X’AB’, X’AC’, X’AD’ as uppercase letters, and the characters X’C0’ and X’D0’ as special characters. In the "C" locale, all these characters are treated as control characters.

"V2CTYPE"

In contrast to the C locale, the collating sequence is set to correspond to the values of the EBCDIC character set.

"GERMANY"

This setting specifies the usual conventions for German-speaking countries.

"De.EDF04F"

Country-specific locale whose conversion table is based on ASCII code ISO 8859-15 ASCII code or EDF04F EBCDIC code and that supports the “DM” currency in the category LC_MONETARY.

"De.EDF04F@euro"


Country-specific locale whose conversion table is based on ASCII code ISO 8859-15 ASCII code or EDF04F EBCDIC code and that supports the “Euro” currency in the category LC_MONETARY.

The strings are preset in the header file locale.h as follows:

Symbolic constant

Default value

LC_C_C

"C"

LC_C_DEFAULT

""

LC_C_V1CTYPE

"V1CTYPE"

LC_C_V2TYPE

"V2CTYPE"

LC_C_GERMANY

"GERMANY"

LC_C_DeEDF04F

"De.EDF04F"

LC_C_DeEDF04F@euro

"De.EDF04F@euro"

(End)

Return val.

String that indicates the current locale for category


if locale is not a null pointer and setlocale() is completed successfully, or
if locale is a null pointer. The locale is not changed.

Null pointer

if setlocale() fails. The locale is not changed.

A subsequent call to setlocale() with the returned string and its associated category will restore that part of the locale. The string returned must not be modified by the program, but may be overwritten by a subsequent call to setlocale().

Notes

The following program statements show how a program can initialize the locale for a language, while selectively modifying it so that regular expressions and string operations can be applied to text recorded in a different language:

setlocale(LC_ALL, "De");

setlocale(LC_COLLATE, "Fr@dict");

Internationalized programs must call the setlocale() function to take a specific language into account. This can be done by calling setlocale() as follows:

setlocale (LC_ALL, "");

This call uses the settings of the environment variables to initialize the locale.
Changing the setting of LC_MESSAGES has no effect on message catalogs that are already opened by calls to catopen().

BS2000
When a program is started, the pointer vector environ is constructed from the variables stored in SYSPOSIX.name. If setlocale() is called with the null string "" as the locale, the environment variables stored in this vector and their values are taken into account. If the queried environment variable is not present, the corresponding value from the POSIX locale applies. (End)

User-specific locales may be implemented in addition to the predefined locales and can be selected using setlocale() (see section “Locale”).

See also

catopen(), ctime(), ctype(), environ, exec, getdate(), gettxt(), isalnum(), isalpha(), iscntrl(), isgraph(), islower(), isprint(), ispunct(), isspace(), isupper(), iswalnum(), iswalpha(), iswcntrl(), iswgraph(), iswlower(), iswprint(), iswpunct(), iswspace(), iswupper(), localeconv(), mblen(), mb-stowcs(), mbtowc(), nl_langinfo(), printf(), scanf(), strcoll()strerror(), strfmon(), strtime(), strtod(), strxrfm(), tolower(), toupper(), towlower(), towupper(), wcscoll(), wcstod(), wcstombs(), wcsxfrm(), wctomb(), langinfo.h, locale.h, section “Locale”.