setlocale

From cppreference.com
< c‎ | locale
Defined in header <locale.h>
char* setlocale( int category, const char* locale);

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

[edit] 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

[edit] Return value

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

[edit] 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.

[edit] Example

[edit] See also

locale categories for setlocale
(macro constant)
C++ documentation for setlocale