1LOCALECONV(P) POSIX Programmer's Manual LOCALECONV(P)
2
3
4
6 localeconv - return locale-specific information
7
9 #include <locale.h>
10
11 struct lconv *localeconv(void);
12
13
15 The localeconv() function shall set the components of an object with
16 the type struct lconv with the values appropriate for the formatting of
17 numeric quantities (monetary and otherwise) according to the rules of
18 the current locale.
19
20 The members of the structure with type char * are pointers to strings,
21 any of which (except decimal_point) can point to "" , to indicate that
22 the value is not available in the current locale or is of zero length.
23 The members with type char are non-negative numbers, any of which can
24 be {CHAR_MAX} to indicate that the value is not available in the cur‐
25 rent locale.
26
27 The members include the following:
28
29 char *decimal_point
30
31 The radix character used to format non-monetary quantities.
32
33 char *thousands_sep
34
35 The character used to separate groups of digits before the deci‐
36 mal-point character in formatted non-monetary quantities.
37
38 char *grouping
39
40 A string whose elements taken as one-byte integer values indi‐
41 cate the size of each group of digits in formatted non-monetary
42 quantities.
43
44 char *int_curr_symbol
45
46 The international currency symbol applicable to the current
47 locale. The first three characters contain the alphabetic
48 international currency symbol in accordance with those specified
49 in the ISO 4217:1995 standard. The fourth character (immediately
50 preceding the null byte) is the character used to separate the
51 international currency symbol from the monetary quantity.
52
53 char *currency_symbol
54
55 The local currency symbol applicable to the current locale.
56
57 char *mon_decimal_point
58
59 The radix character used to format monetary quantities.
60
61 char *mon_thousands_sep
62
63 The separator for groups of digits before the decimal-point in
64 formatted monetary quantities.
65
66 char *mon_grouping
67
68 A string whose elements taken as one-byte integer values indi‐
69 cate the size of each group of digits in formatted monetary
70 quantities.
71
72 char *positive_sign
73
74 The string used to indicate a non-negative valued formatted mon‐
75 etary quantity.
76
77 char *negative_sign
78
79 The string used to indicate a negative valued formatted monetary
80 quantity.
81
82 char int_frac_digits
83
84 The number of fractional digits (those after the decimal-point)
85 to be displayed in an internationally formatted monetary quan‐
86 tity.
87
88 char frac_digits
89
90 The number of fractional digits (those after the decimal-point)
91 to be displayed in a formatted monetary quantity.
92
93 char p_cs_precedes
94
95 Set to 1 if the currency_symbol precedes the value for a non-
96 negative formatted monetary quantity. Set to 0 if the symbol
97 succeeds the value.
98
99 char p_sep_by_space
100
101 Set to a value indicating the separation of the currency_symbol,
102 the sign string, and the value for a non-negative formatted mon‐
103 etary quantity.
104
105 char n_cs_precedes
106
107 Set to 1 if the currency_symbol precedes the value for a nega‐
108 tive formatted monetary quantity. Set to 0 if the symbol suc‐
109 ceeds the value.
110
111 char n_sep_by_space
112
113 Set to a value indicating the separation of the currency_symbol,
114 the sign string, and the value for a negative formatted monetary
115 quantity.
116
117 char p_sign_posn
118
119 Set to a value indicating the positioning of the positive_sign
120 for a non-negative formatted monetary quantity.
121
122 char n_sign_posn
123
124 Set to a value indicating the positioning of the negative_sign
125 for a negative formatted monetary quantity.
126
127 char int_p_cs_precedes
128
129 Set to 1 or 0 if the int_curr_symbol respectively precedes or
130 succeeds the value for a non-negative internationally formatted
131 monetary quantity.
132
133 char int_n_cs_precedes
134
135 Set to 1 or 0 if the int_curr_symbol respectively precedes or
136 succeeds the value for a negative internationally formatted mon‐
137 etary quantity.
138
139 char int_p_sep_by_space
140
141 Set to a value indicating the separation of the int_curr_symbol,
142 the sign string, and the value for a non-negative internation‐
143 ally formatted monetary quantity.
144
145 char int_n_sep_by_space
146
147 Set to a value indicating the separation of the int_curr_symbol,
148 the sign string, and the value for a negative internationally
149 formatted monetary quantity.
150
151 char int_p_sign_posn
152
153 Set to a value indicating the positioning of the positive_sign
154 for a non-negative internationally formatted monetary quantity.
155
156 char int_n_sign_posn
157
158 Set to a value indicating the positioning of the negative_sign
159 for a negative internationally formatted monetary quantity.
160
161
162 The elements of grouping and mon_grouping are interpreted according to
163 the following:
164
165 {CHAR_MAX}
166 No further grouping is to be performed.
167
168 0 The previous element is to be repeatedly used for the remainder
169 of the digits.
170
171 other The integer value is the number of digits that comprise the cur‐
172 rent group. The next element is examined to determine the size
173 of the next group of digits before the current group.
174
175
176 The values of p_sep_by_space, n_sep_by_space, int_p_sep_by_space, and
177 int_n_sep_by_space are interpreted according to the following:
178
179 0 No space separates the currency symbol and value.
180
181 1 If the currency symbol and sign string are adjacent, a space
182 separates them from the value; otherwise, a space separates the
183 currency symbol from the value.
184
185 2 If the currency symbol and sign string are adjacent, a space
186 separates them; otherwise, a space separates the sign string
187 from the value.
188
189
190 For int_p_sep_by_space and int_n_sep_by_space, the fourth character of
191 int_curr_symbol is used instead of a space.
192
193 The values of p_sign_posn, n_sign_posn, int_p_sign_posn, and
194 int_n_sign_posn are interpreted according to the following:
195
196 0 Parentheses surround the quantity and currency_symbol or
197 int_curr_symbol.
198
199 1 The sign string precedes the quantity and currency_symbol or
200 int_curr_symbol.
201
202 2 The sign string succeeds the quantity and currency_symbol or
203 int_curr_symbol.
204
205 3 The sign string immediately precedes the currency_symbol or
206 int_curr_symbol.
207
208 4 The sign string immediately succeeds the currency_symbol or
209 int_curr_symbol.
210
211
212 The implementation shall behave as if no function in this volume of
213 IEEE Std 1003.1-2001 calls localeconv().
214
215 The localeconv() function need not be reentrant. A function that is not
216 required to be reentrant is not required to be thread-safe.
217
219 The localeconv() function shall return a pointer to the filled-in
220 object. The application shall not modify the structure pointed to by
221 the return value which may be overwritten by a subsequent call to
222 localeconv(). In addition, calls to setlocale() with the categories
223 LC_ALL , LC_MONETARY , or LC_NUMERIC may overwrite the contents of the
224 structure.
225
227 No errors are defined.
228
229 The following sections are informative.
230
232 None.
233
235 The following table illustrates the rules which may be used by four
236 countries to format monetary quantities.
237
238 Country Positive Format Negative Format International Format
239 Italy L.1.230 -L.1.230 ITL.1.230
240 Netherlands F 1.234,56 F -1.234,56 NLG 1.234,56
241 Norway kr1.234,56 kr1.234,56- NOK 1.234,56
242 Switzerland SFrs.1,234.56 SFrs.1,234.56C CHF 1,234.56
243
244 For these four countries, the respective values for the monetary mem‐
245 bers of the structure returned by localeconv() are:
246
247 Italy Netherlands Norway Switzerland
248 int_curr_symbol "ITL." "NLG " "NOK " "CHF "
249 currency_symbol "L." "F" "kr" "SFrs."
250 mon_decimal_point "" "," "," "."
251 mon_thousands_sep "." "." "." ","
252 mon_grouping "\3" "\3" "\3" "\3"
253 positive_sign "" "" "" ""
254 negative_sign "-" "-" "-" "C"
255 int_frac_digits 0 2 2 2
256 frac_digits 0 2 2 2
257 p_cs_precedes 1 1 1 1
258 p_sep_by_space 0 1 0 0
259 n_cs_precedes 1 1 1 1
260 n_sep_by_space 0 1 0 0
261 p_sign_posn 1 1 1 1
262 n_sign_posn 1 4 2 2
263 int_p_cs_precedes 1 1 1 1
264 int_n_cs_precedes 1 1 1 1
265 int_p_sep_by_space 0 0 0 0
266 int_n_sep_by_space 0 0 0 0
267 int_p_sign_posn 1 1 1 1
268 int_n_sign_posn 1 4 4 2
269
271 None.
272
274 None.
275
277 isalpha() , isascii() , nl_langinfo() , printf() , scanf() , setlo‐
278 cale() , strcat() , strchr() , strcmp() , strcoll() , strcpy() , strf‐
279 time() , strlen() , strpbrk() , strspn() , strtok() , strxfrm() , str‐
280 tod() , the Base Definitions volume of IEEE Std 1003.1-2001, <lang‐
281 info.h>, <locale.h>
282
284 Portions of this text are reprinted and reproduced in electronic form
285 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
286 -- Portable Operating System Interface (POSIX), The Open Group Base
287 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
288 Electrical and Electronics Engineers, Inc and The Open Group. In the
289 event of any discrepancy between this version and the original IEEE and
290 The Open Group Standard, the original IEEE and The Open Group Standard
291 is the referee document. The original Standard can be obtained online
292 at http://www.opengroup.org/unix/online.html .
293
294
295
296IEEE/The Open Group 2003 LOCALECONV(P)