Each locale specifies conventions for several purposes, including the following:
What multibyte character sequences are valid, and how they are interpreted (see Extended Characters).
Classification of which characters in the local character set are considered alphabetic, and upper- and lower-case conversion conventions (see Character Handling).
The collating sequence for the local language and character set (see Collation Functions).
Formatting of numbers and currency amounts (see Numeric Formatting).
Formatting of dates and times (see Formatting Date and Time).
What language to use for output, including error messages. (The C library doesn't yet help you implement this.)
What language to use for user answers to yes-or-no questions.
What language to use for more complex user input. (The C library doesn't yet help you implement this.)
Some aspects of adapting to the specified locale are handled automatically by the library subroutines. For example, all your program needs to do in order to use the collating sequence of the chosen locale is to use strcoll
or strxfrm
to compare strings.
Other aspects of locales are beyond the comprehension of the library. For example, the library can't automatically translate your program's output messages into other languages. The only way you can support output in the user's favorite language is to program this more or less by hand. (Eventually, we hope to provide facilities to make this easier.)
This chapter discusses the mechanism by which you can modify the current locale. The effects of the current locale on specific library functions are discussed in more detail in the descriptions of those functions.