svcadm(8)을 검색하려면 섹션에서 8 을 선택하고, 맨 페이지 이름에 svcadm을 입력하고 검색을 누른다.
setlocale(3c)
Standard C Library Functions setlocale(3C)
NAME
setlocale - modify and query global locale
SYNOPSIS
#include <locale.h>
char *setlocale(int category, const char *locale);
DESCRIPTION
The setlocale() function selects the appropriate piece of the global
locale for the process as specified by the category and locale argu‐
ments. The category argument may have the following values: LC_CTYPE,
LC_NUMERIC, LC_TIME, LC_COLLATE, LC_MONETARY, LC_MESSAGES, and LC_ALL.
These names are defined in the <locale.h> header. The LC_ALL variable
names all of the global locale categories.
The LC_CTYPE variable affects the behavior of character handling func‐
tions such as isdigit(3C) and tolower(3C), and multibyte character
functions such as mbtowc(3C) and wctomb(3C).
The LC_NUMERIC variable affects the decimal point character and thou‐
sands separator character for the formatted input/output functions and
string conversion functions.
The LC_TIME variable affects the date and time format as delivered by
ascftime(3C), cftime(3C), getdate(3C), strftime(3C), and strptime(3C).
The LC_COLLATE variable affects the sort order produced by collating
functions such as strcoll(3C) and strxfrm(3C).
The LC_MONETARY variable affects the monetary formatted information
returned by localeconv(3C).
The LC_MESSAGES variable affects the behavior of messaging functions
such as dgettext(3C), gettext(3C), and gettxt(3C).
A value of "C" for locale specifies the traditional UNIX system behav‐
ior. At program startup, the equivalent of
setlocale(LC_ALL, "C")
is executed. This has the effect of initializing global locale for each
category to the locale described by the environment "C".
A value of "" for locale specifies that the global locale should be
taken from environment variables. The order in which the environment
variables are checked for the various categories is given below:
tab() box; lw(1.38i) |lw(1.38i) |lw(1.38i) |lw(1.38i) lw(1.38i)
|lw(1.38i) |lw(1.38i) |lw(1.38i) Category1st Env Var2nd Env Var3rd Env
Var _ LC_CTYPE:LC_ALLLC_CTYPELANG _ LC_COLLATE:LC_ALLLC_COLLATELANG _
LC_TIME:LC_ALLLC_TIMELANG _ LC_NUMERIC:LC_ALLLC_NUMERICLANG _ LC_MONE‐
TARY:LC_ALLLC_MONETARYLANG _ LC_MESSAGES:LC_ALLLC_MESSAGESLANG
If a pointer to a string is given for locale, setlocale() attempts to
set the global locale for the given category to locale. If setlocale()
succeeds, locale is returned. If setlocale() fails, a null pointer is
returned and the global locale is not changed.
For category LC_ALL, the behavior is slightly different. If a pointer
to a string is given for locale and LC_ALL is given for category, set‐
locale() attempts to set the global locale for all the categories to
locale. The locale may be a simple locale, consisting of a single
locale, or a composite locale. If the locales for all the categories
are the same after all the attempted locale changes, setlocale() will
return a pointer to the common simple locale. If there is a mixture of
locales among the categories, setlocale() will return a composite
locale.
A null pointer for locale directs setlocale() to query the current
global locale setting and return a pointer to the string associated
with the category for the current global locale. If the category is
LC_ALL and the current global locale is a composite locale, the string
will have locale names for LC_CTYPE, LC_NUMERIC, LC_TIME, LC_COLLATE,
LC_MONETARY, and LC_MESSAGES categories, and in that order, concate‐
nated together where each category's locale name is prefixed with a
slash ('/' or 0x2F) character, for instance, "/en_US.UTF-8/C/C/C/C/C".
Otherwise, the string will have a locale name such as "en_US.UTF-8".
RETURN VALUES
Upon successful completion, setlocale() returns the string associated
with the specified category for the new locale. Otherwise, setlocale()
returns a null pointer and the global locale is not changed.
A null pointer for locale causes setlocale() to return a pointer to the
string associated with the category for the current global locale. The
global locale is not changed.
The string returned by setlocale() is such that a subsequent call with
that string and its associated category will restore that part of the
global locale. The string returned must not be modified by the program,
but may be overwritten by a subsequent call to setlocale().
ERRORS
No errors are defined.
FILES
/usr/lib/locale/locale locale database directory for locale
ATTRIBUTES
See attributes(7) for descriptions of the following attributes:
tab() box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) ATTRIBUTE TYPEAT‐
TRIBUTE VALUE _ CSIEnabled _ Interface StabilityCommitted _ MT-LevelMT-
Safe with exceptions _ StandardSee standards(7).
SEE ALSO
locale(1), ctype(3C), duplocale(3C), freelocale(3C), getdate(3C), get‐
text(3C), gettxt(3C), isdigit(3C), localeconv(3C), locale_fallback(3C),
localelist(3C), localelistfree(3C), mbtowc(3C), newlocale(3C), str‐
coll(3C), strftime(3C), strptime(3C), strxfrm(3C), tolower(3C), uselo‐
cale(3C), wctomb(3C), libc(3LIB), attributes(7), environ(7), locale(7),
locale_alias(7), standards(7)
NOTES
It is unsafe for any thread to change global locale (by calling setlo‐
cale() with a non-null locale argument) in a multithreaded application
while any other thread in the application is using any locale-sensitive
routine. To change global locale in a multithreaded application, setlo‐
cale() should be called prior to using any locale-sensitive routine. To
change current locale, uselocale() should be called. Using setlocale()
to query the current global locale is safe and can be used anywhere in
a multithreaded application.
It is the user's responsibility to ensure that mixed locale categories
are compatible. For example, setting LC_CTYPE=C and LC_TIME=ja (where
ja indicates Japanese) will not work, because Japanese time cannot be
represented in the "C" locale's ASCII codeset.
To get the list of installed locales, instead of calling setlocale()
over a list of potentially installed locales and checking on the return
values, using localelist(3C) is recommended. The localelist() function
does not switch locales and it is more efficient, faster, and fully MT-
safe.
If a string pointed by locale argument has a locale name that does not
yield a usable locale in the current system but it is a locale name
alias that is accepted and supported, such name is internally mapped to
a corresponding canonical locale name which is then used to locate,
load, and return the actual locale defined in the current system. If
successful, the return value of the function is the locale name alias.
If there is no actual locale for the canonical locale name, obviously,
the setlocale() will fail. The accepted and supported locale name
aliases are shown in locale_alias(7).
Oracle Solaris 11.4 9 Jul 2018 setlocale(3C)