Namespaces
Variants
Views
Actions

setlocale

From cppreference.com
< c‎ | locale
Revision as of 21:08, 2 November 2012 by P12bot (Talk | contribs)

Template:ddcl list begin <tr class="t-dsc-header">

<td>
Defined in header <locale.h>
</td>

<td></td> <td></td> <tr class="t-dcl ">

<td class="t-dcl-nopad">
char* setlocale( int category, const char* locale);
</td>

<td class="t-dcl-nopad"> </td> <td class="t-dcl-nopad"> </td> </tr> Template:ddcl list end

The setlocale function installs the specified system locale or its portion as the new C locale. The modifications remain in effect and influences the execution of all locale-sensitive C library functions until the next call to setlocale. If locale is a null pointer, setlocale queries the current C locale without modifying it.

Contents

Parameters

category - locale category identifier, one of the LC_xxx macros. May be null.
locale - system-specific locale identifier. Can be "" for the user-preferred locale or "C" for the minimal locale

Return value

pointer to a narrow null-terminated string identifying the C locale after applying the changes, if any, or null pointer on failure.

Notes

During program startup, the equivalent of setlocale(LC_ALL, "C"); is executed before any user code is run.

Although the return type is char*, modifying the pointed-to characters is undefined behavior.

Because setlocale modifies global state which affects execution of locale-dependent functions, it is undefined behavior to call it from one thread, while another thread is executing any of the following functions: fprintf, isprint, iswdigit, localeconv, tolower, fscanf, ispunct, iswgraph, mblen, toupper, isalnum, isspace, iswlower, mbstowcs, towlower, isalpha, isupper, iswprint, mbtowc, towupper, isblank, iswalnum, iswpunct, setlocale, wcscoll, iscntrl, iswalpha, iswspace, strcoll, wcstod, isdigit, iswblank, iswupper, strerror, wcstombs, isgraph, iswcntrl, iswxdigit, strtod, wcsxfrm, islower, iswctype, isxdigit.

Example

See also

Template:c/locale/dcl list LC categories
C++ documentation for setlocale