$PATH_LOCALE/locale/category
setlocale3
Natural language formatting for c
Usage
#include <locale.h>
char *
setlocale(int category, const char *locale);
Library
Standard C Library (libc, -lc)
Overview
The setlocale() function sets the C library's notion of natural language formatting style for particular sets of routines. Each such style is called a ‘locale’ and is invoked using an appropriate name passed as a C string.
The setlocale() function recognizes several categories of routines. These are the categories and the sets of routines they select:
- LC_ALL
-
Set the entire locale generically.
- LC_COLLATE
-
Set a locale for string collation routines. This controls alphabetic ordering in
strcoll() andstrxfrm(). - LC_CTYPE
-
Set a locale for the ctype(3) and multibyte(3) functions. This controls recognition of upper and lower case, alphabetic or non-alphabetic characters, and so on.
- LC_MESSAGES
-
Set a locale for message catalogs, see catopen(3) function.
- LC_MONETARY
-
Set a locale for formatting monetary values; this affects the
localeconv() function. - LC_NUMERIC
-
Set a locale for formatting numbers. This controls the formatting of decimal points in input and output of floating point numbers in functions such as
printf() andscanf(), as well as values returned bylocaleconv(). - LC_TIME
-
Set a locale for formatting dates and times using the
strftime() function.
Only three locales are defined by default: the empty string "" (which denotes the native environment) and the "C" and "POSIX" locales (which denote the C language environment). A locale argument of NULL causes setlocale() to return the current locale. An argument of "" will determine the name of the new locale taking into account the environment variables LANG and LC_*. If these environment variables yield a locale that is invalid, NULL will be returned and the current locale will remain unchanged. By default, C programs start in the "C" locale. The only function in the library that sets the locale is setlocale(); the locale is never changed as a side effect of some other routine.
Return values
Upon successful completion, setlocale() returns the string associated with the specified category for the requested locale. The setlocale() function returns NULL and fails to change the locale if the given combination of category and locale makes no sense.
Files
-
-
/usr/share/locale/locale/category -
locale file for the locale locale and the category category.
-
/usr/local/share/locale/locale/category -
locale file for the locale locale and the category category.
Errors
No errors are defined.
Releases
161 releases since Mac OS X 10.1; the text changed 6 times.