Select the system locale
Call `setlocale(LC_ALL, "");` near the beginning of a program that prints extended characters. The empty string selects the system default; without the switch, terminal output may appear garbled even on a properly configured system. section 14.3
A locale supplies language-dependent conventions used by parts of the C library. Every C program starts in the normalized `"C"` locale, whose choices for numbers, times, and dates are basically American English. A program can inspect or change its current setting with `setlocale` from `<locale.h>`. Standard C requires support for `"C"` and `""`; other locale names depend on the platform. 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 selects which behavior changes: `LC_NUMERIC` affects the decimal-point character in formatted I/O, `LC_TIME` affects `strftime`, and `LC_ALL` selects every listed category. Collation, character handling, and monetary formatting have separate categories. section 8.7
Extended text also depends on the locale. A multibyte character uses a sequence of bytes for one character; a multibyte string remains null terminated and contains no null byte inside a character. Select the native locale before working with such text, rather than assuming the initial `"C"` locale suits the terminal. section 14.3



