1LOCALE(7) Linux Programmer's Manual LOCALE(7)
2
3
4
6 locale - Description of multi-language support
7
9 #include <locale.h>
10
12 A locale is a set of language and cultural rules. These cover aspects
13 such as language for messages, different character sets, lexicographic
14 conventions, etc. A program needs to be able to determine its locale
15 and act accordingly to be portable to different cultures.
16
17 The header <locale.h> declares data types, functions and macros which
18 are useful in this task.
19
20 The functions it declares are setlocale() to set the current locale,
21 and localeconv() to get information about number formatting.
22
23 There are different categories for local information a program might
24 need; they are declared as macros. Using them as the first argument to
25 the setlocale() function, it is possible to set one of these to the
26 desired locale:
27
28 LC_COLLATE
29 This is used to change the behaviour of the functions strcoll()
30 and strxfrm(), which are used to compare strings in the local
31 alphabet. For example, the German sharp s is sorted as "ss".
32
33 LC_CTYPE
34 This changes the behaviour of the character handling and classi‐
35 fication functions, such as isupper() and toupper(), and the
36 multi-byte character functions such as mblen() or wctomb().
37
38 LC_MONETARY
39 changes the information returned by localeconv() which describes
40 the way numbers are usually printed, with details such as deci‐
41 mal point versus decimal comma. This information is internally
42 used by the function strfmon().
43
44 LC_MESSAGES
45 changes the language messages are displayed in and how an affir‐
46 mative or negative answer looks like. The GNU C-library con‐
47 tains the gettext(), ngettext(), and rpmatch() functions to ease
48 the use of these information. The GNU gettext family of func‐
49 tions also obey the environment variable LANGUAGE.
50
51 LC_NUMERIC
52 changes the information used by the printf() and scanf() family
53 of functions, when they are advised to use the locale-settings.
54 This information can also be read with the localeconv() func‐
55 tion.
56
57 LC_TIME
58 changes the behaviour of the strftime() function to display the
59 current time in a locally acceptable form; for example, most of
60 Europe uses a 24-hour clock versus the 12-hour clock used in the
61 United States.
62
63 LC_ALL All of the above.
64
65 If the second argument to setlocale() is empty string, "", for the
66 default locale, it is determined using the following steps:
67
68 1. If there is a non-null environment variable LC_ALL, the value of
69 LC_ALL is used.
70
71 2. If an environment variable with the same name as one of the cat‐
72 egories above exists and is non-null, its value is used for that
73 category.
74
75 3. If there is a non-null environment variable LANG, the value of
76 LANG is used.
77
78 Values about local numeric formatting is made available in a struct
79 lconv returned by the localeconv() function, which has the following
80 declaration:
81
82 struct lconv {
83
84 /* Numeric (non-monetary) information */
85
86 char *decimal_point; /* Radix character */
87 char *thousands_sep; /* Separator for digit groups to left
88 of radix character */
89 char *grouping; /* Each element is the number of digits in a
90 group; elements with higher indices are
91 further left. An element with value CHAR_MAX
92 means that no further grouping is done. An
93 element with value 0 means that the previous
94 element is used for all groups further left. */
95
96 /* Remaining fields are for monetary information */
97
98 char *int_curr_symbol; /* First three chars are a currency symbol
99 from ISO 4217. Fourth char is the
100 separator. Fifth char is ' '. */
101 char *currency_symbol; /* Local currency symbol */
102 char *mon_decimal_point; /* Radix character */
103 char *mon_thousands_sep; /* Like `thousands_sep' above */
104 char *mon_grouping; /* Like `grouping' above */
105 char *positive_sign; /* Sign for positive values */
106 char *negative_sign; /* Sign for negative values */
107 char int_frac_digits; /* Int'l fractional digits */
108 char frac_digits; /* Local fractional digits */
109 char p_cs_precedes; /* 1 if currency_symbol precedes a
110 positive value, 0 if succeeds */
111 char p_sep_by_space; /* 1 if a space separates currency_symbol
112 from a positive value */
113 char n_cs_precedes; /* 1 if currency_symbol precedes a
114 negative value, 0 if succeeds */
115 char n_sep_by_space; /* 1 if a space separates currency_symbol
116 from a negative value */
117 /* Positive and negative sign positions:
118 0 Parentheses surround the quantity and currency_symbol.
119 1 The sign string precedes the quantity and currency_symbol.
120 2 The sign string succeeds the quantity and currency_symbol.
121 3 The sign string immediately precedes the currency_symbol.
122 4 The sign string immediately succeeds the currency_symbol. */
123 char p_sign_posn;
124 char n_sign_posn;
125 };
126
128 POSIX.1-2001.
129
130 The GNU gettext functions are specified in LI18NUX2000.
131
133 locale(1), localedef(1), gettext(3), localeconv(3), ngettext(3),
134 nl_langinfo(3), rpmatch(3), setlocale(3), strcoll(3), strfmon(3), strf‐
135 time(3), strxfrm(3)
136
137
138
139Linux 1993-04-24 LOCALE(7)