Name
setlocale
Synopsis
Gets or sets locale information
#include <locale.h> char *setlocale
( intcategory
, const char *locale_name
);
The setlocale()
function
allows you to adapt the program to the local conditions of a given
regional and cultural environment—called a locale—such as clocks and calendars,
decimal point and currency symbol characters, and other conventions.
The setlocale()
function returns
a pointer to a string that identifies the new locale, or the current
locale if you pass the function a null pointer as its second
argument.
The locale conventions are classed in categories. You can set the individual
categories of the program’s locale individually. The header file
locale.h defines the following
macros to identify each category in the first argument to setlocale()
:
LC_ALL
Includes all the other categories.
LC_COLLATE
Affects the functions
strcoll()
,strxfrm()
,wcscoll()
, andwcsxfrm()
.LC_CTYPE
Affects the character-handling functions (such as
isalpha()
,tolower()
, and so on), and the multibyte and wide-character functions.LC_MONETARY
Affects the monetary format information provided by the
localeconv()
function.LC_NUMERIC
Affects the nonmonetary numeral format information provided by the
localeconv()
function, and the decimal point used by theprintf()
andscanf()
functions, and by string conversion functions such asstrtod()
.LC_TIME
Affects the time and date string format produced by the
strftime()
andwcsftime()
functions.
The second argument to setlocale()
,
locale_name
, is a ...
Get C in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.