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_ALLIncludes all the other categories.
LC_COLLATEAffects the functions
strcoll(),strxfrm(),wcscoll(), andwcsxfrm().LC_CTYPEAffects the character-handling functions (such as
isalpha(),tolower(), and so on), and the multibyte and wide-character functions.LC_MONETARYAffects the monetary format information provided by the
localeconv()function.LC_NUMERICAffects 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_TIMEAffects the time and date string format produced by the
strftime()andwcsftime()functions.
The second argument to setlocale(),
locale_name, is a ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access