| Skip Navigation Links | |
| Exit Print View | |
![]() | man pages section 3: Basic Library Functions Oracle Solaris 11 Information Library |
enable_extended_FILE_stdio(3C)
posix_spawnattr_getschedparam(3C)
posix_spawnattr_getschedpolicy(3C)
posix_spawnattr_getsigdefault(3C)
posix_spawnattr_getsigignore_np(3C)
posix_spawnattr_getsigmask(3C)
posix_spawnattr_setschedparam(3C)
posix_spawnattr_setschedpolicy(3C)
posix_spawnattr_setsigdefault(3C)
posix_spawnattr_setsigignore_np(3C)
posix_spawnattr_setsigmask(3C)
posix_spawn_file_actions_addclose(3C)
posix_spawn_file_actions_addclosefrom_np(3C)
posix_spawn_file_actions_adddup2(3C)
posix_spawn_file_actions_addopen(3C)
posix_spawn_file_actions_destroy(3C)
posix_spawn_file_actions_init(3C)
pthread_attr_getdetachstate(3C)
pthread_attr_getinheritsched(3C)
pthread_attr_getschedparam(3C)
pthread_attr_getschedpolicy(3C)
pthread_attr_setdetachstate(3C)
pthread_attr_setinheritsched(3C)
pthread_attr_setschedparam(3C)
pthread_attr_setschedpolicy(3C)
pthread_barrierattr_destroy(3C)
pthread_barrierattr_getpshared(3C)
pthread_barrierattr_setpshared(3C)
pthread_condattr_getpshared(3C)
pthread_condattr_setpshared(3C)
pthread_cond_reltimedwait_np(3C)
pthread_key_create_once_np(3C)
pthread_mutexattr_getprioceiling(3C)
pthread_mutexattr_getprotocol(3C)
pthread_mutexattr_getpshared(3C)
pthread_mutexattr_getrobust(3C)
pthread_mutexattr_setprioceiling(3C)
pthread_mutexattr_setprotocol(3C)
pthread_mutexattr_setpshared(3C)
pthread_mutexattr_setrobust(3C)
pthread_mutex_getprioceiling(3C)
pthread_mutex_reltimedlock_np(3C)
pthread_mutex_setprioceiling(3C)
pthread_rwlockattr_destroy(3C)
pthread_rwlockattr_getpshared(3C)
pthread_rwlockattr_setpshared(3C)
pthread_rwlock_reltimedrdlock_np(3C)
pthread_rwlock_reltimedwrlock_np(3C)
pthread_rwlock_timedrdlock(3C)
pthread_rwlock_timedwrlock(3C)
rctlblk_get_enforced_value(3C)
- modify and query a program's locale
#include <locale.h>char *setlocale(intcategory,const char *locale);
Thesetlocale() function selects the appropriate piece of the program's locale asspecified by thecategory andlocale arguments. Thecategory argument may havethe following values:LC_CTYPE,LC_NUMERIC,LC_TIME,LC_COLLATE,LC_MONETARY,LC_MESSAGES, andLC_ALL. Thesenames are defined in the <locale.h> header. TheLC_ALL variable namesall of a program's locale categories.
TheLC_CTYPE variable affects the behavior of character handling functions such asisdigit(3C) andtolower(3C), and multibyte character functions such asmbtowc(3C) andwctomb(3C).
TheLC_NUMERIC variable affects the decimal point character and thousands separator characterfor the formatted input/output functions and string conversion functions.
TheLC_TIME variable affects the date and time format as delivered byascftime(3C),cftime(3C),getdate(3C),strftime(3C), andstrptime(3C).
TheLC_COLLATE variable affects the sort order produced by collating functions suchasstrcoll(3C) andstrxfrm(3C).
TheLC_MONETARY variable affects the monetary formatted information returned bylocaleconv(3C).
TheLC_MESSAGES variable affects the behavior of messaging functions such asdgettext(3C),gettext(3C), andgettxt(3C).
A value of “C” forlocale specifies the traditional UNIX system behavior.At program startup, the equivalent of
setlocale(LC_ALL, "C")
is executed. This has the effect of initializing each category to thelocale described by the environment “C”.
A value of “” forlocale specifies that the locale should betaken from environment variables. The order in which the environment variables arechecked for the various categories is given below:
|
If a pointer to a string is given forlocale,setlocale() attemptsto set the locale for the given category tolocale. Ifsetlocale()succeeds,locale is returned. Ifsetlocale() fails, a null pointer is returned andthe program's locale is not changed.
For categoryLC_ALL, the behavior is slightly different. If a pointer toa string is given forlocale andLC_ALL is given forcategory,setlocale() attempts to set the locale for all the categories tolocale. Thelocale may be a simple locale, consisting of a single locale, ora composite locale. If the locales for all the categories are thesame after all the attempted locale changes,setlocale() will return a pointerto the common simple locale. If there is a mixture of locales amongthe categories,setlocale() will return a composite locale.
Upon successful completion,setlocale() returns the string associated with the specified categoryfor the new locale. Otherwise,setlocale() returns a null pointer and theprogram's locale is not changed.
A null pointer forlocale causessetlocale() to return a pointer tothe string associated with thecategory for the program's current locale. The program's locale is not changed.
The string returned bysetlocale() is such that a subsequent call withthat string and its associatedcategory will restore that part of theprogram's locale. The string returned must not be modified by the program,but may be overwritten by a subsequent call tosetlocale().
No errors are defined.
locale database directory forlocale
Seeattributes(5) for descriptions of the following attributes:
|
locale(1),ctype(3C),getdate(3C)gettext(3C),gettxt(3C),isdigit(3C),libc(3LIB),localelist(3C),localelistfree(3C),localeconv(3C),mbtowc(3C),strcoll(3C),strftime(3C),strptime(3C)strxfrm(3C)tolower(3C),wctomb(3C),attributes(5),environ(5),locale(5),locale_alias(5),standards(5)
It is unsafe for any thread to change locale (by callingsetlocale()with a non-null locale argument) in a multithreaded application while any otherthread in the application is using any locale-sensitive routine. To change localein a multithreaded application,setlocale() should be called prior to using anylocale-sensitive routine. Usingsetlocale() to query the current locale is safe andcan be used anywhere in a multithreaded application except when some otherthread is changing locale.
It is the user's responsibility to ensure that mixed locale categories arecompatible. For example, settingLC_CTYPE=C andLC_TIME=ja (whereja indicates Japanese) willnot work, because Japanese time cannot be represented in the “C” locale's ASCIIcodeset.
To get the list of installed locales, instead of callingsetlocale() overa list of potentially installed locales and checking on the return values,usinglocalelist(3C) is recommended. Thelocalelist() function does not switch locales andit is more efficient, faster, and fully MT-safe.
If a string pointed by locale argument has a locale name thatdoes not yield a usable locale in the current system but itis a locale name alias that is accepted and supported, such nameis internally mapped to a corresponding canonical locale name which is thenused to locate, load, and return the actual locale defined in the currentsystem. If successful, the return value of the function is the localename alias. If there is no actual locale for the canonical localename, obviously, thesetlocale() will fail. The accepted and supported locale namealiases are shown inlocale_alias(5).
Copyright © 2011, Oracle and/or its affiliates. All rights reserved.Legal Notices | ![]() ![]() |