Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

setlocale(3) [mojave man page]

SETLOCALE(3)						   BSD Library Functions Manual 					      SETLOCALE(3)

NAME
setlocale -- natural language formatting for C LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <locale.h> char * setlocale(int category, const char *locale); DESCRIPTION
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() and strxfrm(). 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 num- bers in functions such as printf() and scanf(), as well as values returned by localeconv(). 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
$PATH_LOCALE/locale/category /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. SEE ALSO
colldef(1), mklocale(1), catopen(3), ctype(3), localeconv(3), multibyte(3), strcoll(3), strxfrm(3), euc(5), utf8(5), environ(7) STANDARDS
The setlocale() function conforms to ISO/IEC 9899:1999 (``ISO C99''). HISTORY
The setlocale() function first appeared in 4.4BSD. BSD
November 21, 2003 BSD

Check Out this Related Man Page

SETLOCALE(3)								 1							      SETLOCALE(3)

setlocale - Set locale information

SYNOPSIS
string setlocale (int $category, string $locale, [string $...]) DESCRIPTION
string setlocale (int $category, array $locale) Sets locale information. PARAMETERS
o $category -$category is a named constant specifying the category of the functions affected by the locale setting: o LC_ALL for all of the below o LC_COLLATE for string comparison, see strcoll(3) o LC_CTYPE for character classification and conversion, for example strtoupper(3) o LC_MONETARY for localeconv(3) o LC_NUMERIC for decimal separator (See also localeconv(3)) o LC_TIME for date and time formatting with strftime(3) o LC_MESSAGES for system responses (available if PHP was compiled with libintl) o $locale - If $locale is NULL or the empty string "", the locale names will be set from the values of environment variables with the same names as the above categories, or from "LANG". If $locale is "0", the locale setting is not affected, only the current setting is returned. If $locale is an array or followed by additional parameters then each array element or parameter is tried to be set as new locale until success. This is useful if a locale is known under different names on different systems or for providing a fall- back for a possibly not available locale. o $... - (Optional string or array parameters to try as locale settings until success.) Note On Windows, setlocale(LC_ALL, '') sets the locale names from the system's regional/language settings (accessible via Control Panel). RETURN VALUES
Returns the new current locale, or FALSE if the locale functionality is not implemented on your platform, the specified locale does not exist or the category name is invalid. An invalid category name also causes a warning message. Category/locale names can be found in RFC 1766 and ISO 639. Different systems have different naming schemes for locales. Note The return value of setlocale(3) depends on the system that PHP is running. It returns exactly what the system setlocale function returns. CHANGELOG
+--------+---------------------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------------------+ | 7.0.0 | | | | | | | Support for the $category parameter passed as a | | | string has been removed. Only LC_* constants can | | | be used as of this version. | | | | | 5.3.0 | | | | | | | This function now throws an E_DEPRECATED notice | | | if a string is passed to the $category parameter | | | instead of one of the LC_* constants. | | | | +--------+---------------------------------------------------+ EXAMPLES
Example #1 setlocale(3) Examples <?php /* Set locale to Dutch */ setlocale(LC_ALL, 'nl_NL'); /* Output: vrijdag 22 december 1978 */ echo strftime("%A %e %B %Y", mktime(0, 0, 0, 12, 22, 1978)); /* try different possible locale names for german as of PHP 4.3.0 */ $loc_de = setlocale(LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge'); echo "Preferred locale for german on this system is '$loc_de'"; ?> Example #2 setlocale(3) Examples for Windows <?php /* Set locale to Dutch */ setlocale(LC_ALL, 'nld_nld'); /* Output: vrijdag 22 december 1978 */ echo strftime("%A %d %B %Y", mktime(0, 0, 0, 12, 22, 1978)); /* try different possible locale names for german as of PHP 4.3.0 */ $loc_de = setlocale(LC_ALL, 'de_DE@euro', 'de_DE', 'deu_deu'); echo "Preferred locale for german on this system is '$loc_de'"; ?> NOTES
Warning The locale information is maintained per process, not per thread. If you are running PHP on a multithreaded server API like IIS, HHVM or Apache on Windows, you may experience sudden changes in locale settings while a script is running, though the script itself never called setlocale(3). This happens due to other scripts running in different threads of the same process at the same time, changing the process-wide locale using setlocale(3). Tip Windows users will find useful information about $locale strings at Microsoft's MSDN website. Supported language strings can be found in the language strings documentation and supported country/region strings in the country/region strings documentation. PHP Documentation Group SETLOCALE(3)
Man Page