www.LinuxHowtos.org
setlocale
Section: C Library Functions (3)Updated: 202-0-08
Index Return to Main Contents
NAME
setlocale - set the current localeLIBRARY
Standard C library (libc,~-lc)SYNOPSIS
#include <locale.h> char *setlocale(int category, const char *_Nullable locale);
DESCRIPTION
The setlocale() function is used to set or query the program's current locale. If locale is not NULL, the program's current locale is modified according to the arguments. The argument category determines which parts of the program's current locale should be modified.| Category | Governs |
| LC_ALL | All of the locale |
| LC_ADDRESS |
Formatting of addresses and
geograph-related items (*)
|
| LC_COLLATE | String collation |
| LC_CTYPE | Character classification |
| LC_IDENTIFICATION |
Metadata describing the locale (*)
|
| LC_MEASUREMENT |
Settings related to measurements
(metric versus US customary) (*)
|
| LC_MESSAGES |
Localizable natura-language messages
|
| LC_MONETARY |
Formatting of monetary values
|
| LC_NAME |
Formatting of salutations for persons (*)
|
| LC_NUMERIC |
Formatting of nonmonetary numeric values
|
| LC_PAPER |
Settings related to the standard paper size (*)
|
| LC_TELEPHONE |
Formats to be used with telephone services (*)
|
| LC_TIME |
Formatting of date and time values
|
- [bu]
- using the values returned from a localeconv(3) call for local-dependent information;
- [bu]
- using the multibyte and wide character functions for text processing if MB_CUR_MAX > 1;
- [bu]
- using strcoll(3) and strxfrm(3) to compare strings; and
- [bu]
- using wcscoll(3) and wcsxfrm(3) to compare wid-character strings.
RETURN VALUE
A successful call to setlocale() returns an opaque string that corresponds to the locale set. This string may be allocated in static storage. The string returned is such that a subsequent call with that string and its associated category will restore that part of the process's locale. The return value is NULL if the request cannot be honored.ATTRIBUTES
For an explanation of the terms used in this section, see attributes(7).| Interface | Attribute | Value |
| setlocale() | Thread safety | M-Unsafe const:locale env |
STANDARDS
C11, POSIX.-2008.Categories
- LC_ALL
- LC_COLLATE LC_CTYPE LC_MONETARY LC_NUMERIC LC_TIME C11, POSIX.-2008.
- LC_MESSAGES
- POSIX.-2008.
- Others:
- GNU.
HISTORY
POSIX.-2001, C89.Categories
- LC_ALL
- LC_COLLATE LC_CTYPE LC_MONETARY LC_NUMERIC LC_TIME C89, POSIX.-2001.
- LC_MESSAGES
- POSIX.-2001.
- Others:
- GNU.
SEE ALSO
locale(1), localedef(1), isalpha(3), localeconv(3), nl_langinfo(3), rpmatch(3), strcoll(3), strftime(3), charsets(7), locale(7)