A locale is a set of language- and culture-dependent conventions for interpreting and presenting data. In C, it affects operations such as character classification, string comparison, numeric formatting, and date and time formatting. section 8.7
setlocale(LC_ALL, "");
/* Multibyte character printing only works after the locale
has been switched. */
draw_sep(TOPLEFT " © 2014 j𝜀nz ' g𝜔z,t𝜀t ", TOPRIGHT);
Switch to the system’s native locale near the start of a program before printing extended characters. Without the switch, terminal output may be garbled; correct display also depends on the system being properly configured. section 14.3
At startup, C sets the locale to "C", with essentially American English conventions for numbers, times, and dates. The setlocale function in <locale.h> sets or inspects the current locale. The standard also guarantees the locale name "", which selects the system default. Environment variables such as LANG and LC_ALL commonly provide language settings, though their availability depends on the operating system. section 8.7
Table 8.17 Categories for the setlocale function
| Category | Scope |
LC_COLLATE |
String comparison through strcoll and strxfrm |
LC_CTYPE |
Character classification and handling functions; see subsection 8.5. |
LC_MONETARY |
Monetary formatting information, localeconv |
LC_NUMERIC |
Decimal-point character for formatted I/O, localeconv |
LC_TIME |
strftime; see subsection 8.6 |
LC_ALL |
All of the above |
The category argument selects which conventions setlocale addresses. LC_ALL covers all listed categories; a narrower category changes or inspects only the corresponding part of the language environment. Additional categories may be platform-dependent. section 8.7
A multibyte character is a sequence of bytes representing one extended character. Multibyte characters contain no null bytes, and multibyte strings are null terminated, so ordinary string functions such as strcpy can work with them. section 14.3



