1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
|
.\"
.\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
.\" permission to reproduce portions of its copyrighted documentation.
.\" Original documentation from The Open Group can be obtained online at
.\" http://www.opengroup.org/bookstore/.
.\"
.\" The Institute of Electrical and Electronics Engineers and The Open
.\" Group, have given us permission to reprint portions of their
.\" documentation.
.\"
.\" In the following statement, the phrase ``this text'' refers to portions
.\" of the system documentation.
.\"
.\" Portions of this text are reprinted and reproduced in electronic form
.\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
.\" Standard for Information Technology -- Portable Operating System
.\" Interface (POSIX), The Open Group Base Specifications Issue 6,
.\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
.\" Engineers, Inc and The Open Group. In the event of any discrepancy
.\" between these versions and the original IEEE and The Open Group
.\" Standard, the original IEEE and The Open Group Standard is the referee
.\" document. The original Standard can be obtained online at
.\" http://www.opengroup.org/unix/online.html.
.\"
.\" This notice shall appear on any product containing this material.
.\"
.\" The contents of this file are subject to the terms of the
.\" Common Development and Distribution License (the "License").
.\" You may not use this file except in compliance with the License.
.\"
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
.\" or http://www.opensolaris.org/os/licensing.
.\" See the License for the specific language governing permissions
.\" and limitations under the License.
.\"
.\" When distributing Covered Code, include this CDDL HEADER in each
.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
.\" If applicable, add the following below this CDDL HEADER, with the
.\" fields enclosed by brackets "[]" replaced with your own identifying
.\" information: Portions Copyright [yyyy] [name of copyright owner]
.\"
.\"
.\" Copyright 1989 AT&T
.\" Copyright (c) 2001, The IEEE and The Open Group. All Rights Reserved.
.\" Portions Copyright (c) 2002, Sun Microsystems, Inc. All Rights Reserved.
.\"
.TH LOCALECONV 3C "Dec 12, 2003"
.SH NAME
localeconv \- get numeric formatting information
.SH SYNOPSIS
.LP
.nf
#include <locale.h>
\fBstruct lconv *\fR\fBlocaleconv\fR(\fBvoid\fR);
.fi
.SH DESCRIPTION
.sp
.LP
The \fBlocaleconv()\fR function sets the components of an object with type
\fBstruct lconv\fR (defined in \fB<locale.h>\fR) with the values appropriate
for the formatting of numeric quantities (monetary and otherwise) according to
the rules of the current locale (see \fBsetlocale\fR(3C)). The definition of
\fBstruct lconv\fR is given below (the values for the fields in the "C" locale
are given in comments).
.sp
.in +2
.nf
char *decimal_point; /* "." */
char *thousands_sep; /* "" (zero length string) */
char *grouping; /* "" */
char *int_curr_symbol; /* "" */
char *currency_symbol; /* "" */
char *mon_decimal_point; /* "" */
char *mon_thousands_sep; /* "" */
char *mon_grouping; /* "" */
char *positive_sign; /* "" */
char *negative_sign; /* "" */
char int_frac_digits; /* CHAR_MAX */
char frac_digits; /* CHAR_MAX */
char p_cs_precedes; /* CHAR_MAX */
char p_sep_by_space; /* CHAR_MAX */
char n_cs_precedes; /* CHAR_MAX */
char n_sep_by_space; /* CHAR_MAX */
char p_sign_posn; /* CHAR_MAX*/
char n_sign_posn; /* CHAR_MAX */
.fi
.in -2
.sp
.LP
The following members are also available to SUSv3-conforming applications. See
.BR standards (7)
.sp
.in +2
.nf
char int_p_cs_precedes; /* CHAR_MAX */
char int_p_sep_by_space; /* CHAR_MAX */
char int_n_cs_precedes; /* CHAR_MAX */
char int_n_sep_by_space; /* CHAR_MAX */
char int_p_sign_posn; /* CHAR_MAX */
char int_n_sign_posn; /* CHAR_MAX */
.fi
.in -2
.sp
.LP
The members of the structure with type \fBchar *\fR are strings, any of which
(except \fBdecimal_point\fR) can point to a null string (""), to indicate that
the value is not available in the current locale or is of zero length. The
members with type \fBchar\fR are non-negative numbers, any of which can be
\fBCHAR_MAX\fR (defined in the \fB<limits.h>\fR header) to indicate that the
value is not available in the current locale. The members are the following:
.sp
.ne 2
.na
\fB\fBchar *decimal_point\fR\fR
.ad
.RS 27n
The decimal-point character used to format non-monetary quantities.
.RE
.sp
.ne 2
.na
\fB\fBchar *thousands_sep\fR\fR
.ad
.RS 27n
The character used to separate groups of digits to the left of the
decimal-point character in formatted non-monetary quantities.
.RE
.sp
.ne 2
.na
\fB\fBchar *grouping\fR\fR
.ad
.RS 27n
A string whose elements taken as one-byte integer values indicate the size of
each group of digits in formatted non-monetary quantities.
.RE
.sp
.ne 2
.na
\fB\fBchar *int_curr_symbol\fR\fR
.ad
.RS 27n
The international currency symbol applicable to the current locale. The first
three characters contain the alphabetic international currency symbol in
accordance with those specified in the ISO 4217: 1995 standard. The fourth
character (immediately preceding the null byte) is the character used to
separate the international currency symbol from the monetary quantity.
.RE
.sp
.ne 2
.na
\fB\fBchar *currency_symbol\fR\fR
.ad
.RS 27n
The local currency symbol applicable to the current locale.
.RE
.sp
.ne 2
.na
\fB\fBchar *mon_decimal_point\fR\fR
.ad
.RS 27n
The decimal point used to format monetary quantities.
.RE
.sp
.ne 2
.na
\fB\fBchar *mon_thousands_sep\fR\fR
.ad
.RS 27n
The separator for groups of digits to the left of the decimal point in
formatted monetary quantities.
.RE
.sp
.ne 2
.na
\fB\fBchar *mon_grouping\fR\fR
.ad
.RS 27n
A string whose elements taken as one-byte integer values indicate the size of
each group of digits in formatted monetary quantities.
.RE
.sp
.ne 2
.na
\fB\fBchar *positive_sign\fR\fR
.ad
.RS 27n
The string used to indicate a non-negative-valued formatted monetary quantity.
.RE
.sp
.ne 2
.na
\fB\fBchar *negative_sign\fR\fR
.ad
.RS 27n
The string used to indicate a negative-valued formatted monetary quantity.
.RE
.sp
.ne 2
.na
\fB\fBchar int_frac_digits\fR\fR
.ad
.RS 27n
The number of fractional digits (those to the right of the decimal point) to be
displayed in an internationally formatted monetary quantity.
.RE
.sp
.ne 2
.na
\fB\fBchar frac_digits\fR\fR
.ad
.RS 27n
The number of fractional digits (those to the right of the decimal point) to be
displayed in a formatted monetary quantity.
.RE
.sp
.ne 2
.na
\fB\fBchar p_cs_precedes\fR\fR
.ad
.RS 27n
Set to 1 or 0 if the \fBcurrency_symbol\fR respectively precedes or succeeds
the value for a non-negative formatted monetary quantity.
.RE
.sp
.ne 2
.na
\fB\fBchar p_sep_by_space\fR\fR
.ad
.RS 27n
Set to 0 if no space separates the \fBcurrency_symbol\fR or
\fBint_curr_symbol\fR from the value for a non-negative formatted monetary
quantity. Set to 1 if a space separates the symbol from the value; and set to 2
if a space separates the symbol and the sign string, if adjacent.
.RE
.sp
.ne 2
.na
\fB\fBchar n_cs_precedes\fR\fR
.ad
.RS 27n
Set to 1 or 0 if the \fBcurrency_symbol\fR respectively precedes or succeeds
the value for a negative formatted monetary quantity.
.RE
.sp
.ne 2
.na
\fB\fBchar n_sep_by_space\fR\fR
.ad
.RS 27n
Set to 0 if no space separates the \fBcurrency_symbol\fR or
\fBint_curr_symbol\fR from the value for a negative formatted monetary
quantity. Set to 1 if a space separates the symbol from the value; and set to 2
if a space separates the symbol and the sign string, if adjacent.
.RE
.sp
.ne 2
.na
\fB\fBchar p_sign_posn\fR\fR
.ad
.RS 27n
Set to a value indicating the positioning of the \fBpositive_sign\fR for a
non-negative formatted monetary quantity.
.RE
.sp
.ne 2
.na
\fB\fBchar n_sign_posn\fR\fR
.ad
.RS 27n
Set to a value indicating the positioning of the \fBnegative_sign\fR for a
negative formatted monetary quantity.
.RE
.sp
.ne 2
.na
\fB\fBchar int_p_cs_precedes\fR\fR
.ad
.RS 27n
Set to 1 or 0 if the \fBint_curr_symbol\fR respectively precedes or succeeds
the value for a non-negative internationally formatted monetary quantity.
.RE
.sp
.ne 2
.na
\fB\fBchar int_n_cs_precedes\fR\fR
.ad
.RS 27n
Set to 1 or 0 if the \fBint_curr_symbol\fR respectively precedes or succeeds
the value for a negative internationally formatted monetary quantity.
.RE
.sp
.ne 2
.na
\fB\fBchar int_p_sep_by_space\fR\fR
.ad
.RS 27n
Set to a value indicating the separation of the \fBint_curr_symbol\fR, the sign
string, and the value for a non-negative internationally formatted monetary
quantity.
.RE
.sp
.ne 2
.na
\fB\fBchar int_n_sep_by_space\fR\fR
.ad
.RS 27n
Set to a value indicating the separation of the \fBint_curr_symbol\fR, the sign
string, and the value for a negative internationally formatted monetary
quantity.
.RE
.sp
.ne 2
.na
\fB\fBchar int_p_sign_posn\fR\fR
.ad
.RS 27n
Set to a value indicating the positioning of the \fBpositive_sign\fR for a
non-negative internationally formatted monetary quantity.
.RE
.sp
.ne 2
.na
\fB\fBchar int_n_sign_posn\fR\fR
.ad
.RS 27n
Set to a value indicating the positioning of the \fBnegative_sign\fR for a
negative internationally formatted monetary quantity.
.RE
.sp
.LP
The elements of \fBgrouping\fR and \fBmon_grouping\fR are interpreted according
to the following:
.sp
.ne 2
.na
\fB{\fBCHAR_MAX\fR}\fR
.ad
.RS 14n
No further grouping is to be performed.
.RE
.sp
.ne 2
.na
\fB0\fR
.ad
.RS 14n
The previous element is to be repeatedly used for the remainder of the digits.
.RE
.sp
.ne 2
.na
\fB\fIother\fR\fR
.ad
.RS 14n
The integer value is the number of digits that comprise the current group. The
next element is examined to determine the size of the next group of digits
before the current group.
.RE
.sp
.LP
The values of \fBp_sep_by_space\fR, \fBn_sep_by_space\fR,
\fBint_p_sep_by_space\fR, and \fBint_n_sep_by_space\fR are interpreted
according to the following:
.sp
.ne 2
.na
\fB0\fR
.ad
.RS 5n
No space separates the currency symbol and value.
.RE
.sp
.ne 2
.na
\fB1\fR
.ad
.RS 5n
If the currency symbol and sign string are adjacent, a space separates them
from the value; otherwise, a space separates the currency symbol from the
value.
.RE
.sp
.ne 2
.na
\fB2\fR
.ad
.RS 5n
If the currency symbol and sign string are adjacent, a space separates them;
otherwise, a space separates the sign string from the value.
.RE
.sp
.LP
In an SUSv3-conforming application, for \fBint_p_sep_by_space\fR and
\fBint_n_sep_by_space\fR, the fourth character of \fBint_curr_symbol\fR is used
instead of a space.
.sp
.LP
The values of \fBp_sign_posn\fR, \fBn_sign_posn\fR, \fBint_p_sign_posn\fR, and
\fBint_n_sign_posn\fR are interpreted according to the following:
.sp
.ne 2
.na
\fB0\fR
.ad
.RS 5n
Parentheses surround the quantity and \fBcurrency_symbol\fR or
\fBint_curr_symbol\fR.
.RE
.sp
.ne 2
.na
\fB1\fR
.ad
.RS 5n
The sign string precedes the quantity and \fBcurrency_symbol\fR or
\fBint_curr_symbol\fR.
.RE
.sp
.ne 2
.na
\fB2\fR
.ad
.RS 5n
The sign string succeeds the quantity and \fBcurrency_symbol\fR or
\fBint_curr_symbol\fR.
.RE
.sp
.ne 2
.na
\fB3\fR
.ad
.RS 5n
The sign string immediately precedes the \fBcurrency_symbol\fR or
\fBint_curr_symbol\fR.
.RE
.sp
.ne 2
.na
\fB4\fR
.ad
.RS 5n
The sign string immediately succeeds the \fBcurrency_symbol\fR or
\fBint_curr_symbol\fR.
.RE
.SH RETURN VALUES
.sp
.LP
The \fBlocaleconv()\fR function returns a pointer to the filled-in object. The
structure pointed to by the return value may be overwritten by a subsequent
call to \fBlocaleconv()\fR.
.SH EXAMPLES
.LP
\fBExample 1 \fRRules used by four countries to format monetary quantities.
.sp
.LP
The following table illustrates the rules used by four countries to format
monetary quantities.
.sp
.sp
.TS
l | l | l | l
l | l | l | l .
\fBCountry\fR \fBPositive\fR \fBNegative\fR \fBInternational\fR
_
Italy (IT) L.1.234 \(miL.1.234 ITL.1.234
_
Netherlands (NE) F 1.234,56 F \(mi1.234,56 NLG 1.234,56
_
Norway (NO) kr1.234,56 kr1.234,56\(mi NOK 1.234,56
_
Switzerland (SW) SFrs.1,234.56 SFrs.1,234.56C CHF 1,234.56
.TE
.sp
.LP
For these four countries, the respective values for the monetary members of the
structure returned by \fBlocaleconv()\fR are as follows:
.sp
.sp
.TS
l l l l l
l l l l l .
\fBIT\fR \fBNE\fR \fBNO\fR \fBSW\fR
\fBint_curr_symbol\fR "ITL." "NLG " "NOK " "CHF "
\fBcurrency_symbol\fR "L." "F" "kr" "SFrs."
\fBmon_decimal_point\fR "" "," "," "."
\fBmon_thousands_sep\fR "." "." "." ","
\fBmon_grouping\fR "\e3" "\e3" "\e3" "\e3"
\fBpositive_sign\fR "" "" "" ""
\fBnegative_sign\fR "-" "-" "-" "C"
\fBint_frac_digits\fR 0 2 2 2
\fBfrac_digits\fR 0 2 2 2
\fBp_cs_precedes\fR 1 1 1 1
\fBp_sep_by_space\fR 0 1 0 0
\fBn_cs_precedes\fR 1 1 1 1
\fBn_sep_by_space\fR 0 1 0 0
\fBp_sign_posn\fR 1 1 1 1
\fBn_sign_posn\fR 1 4 2 2
\fBint_p_cs_precedes\fR 1 1 1 1
\fBint_n_cs_precedes\fR 1 1 1 1
\fBint_p_sep_by_space\fR 0 0 0 0
\fBint_n_sep_by_space\fR 0 0 0 0
\fBint_p_sign_posn\fR 1 1 1 1
\fBint_n_sign_posn\fR 1 4 4 2
.TE
.SH ATTRIBUTES
.sp
.LP
See \fBattributes\fR(7) for descriptions of the following attributes:
.sp
.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE ATTRIBUTE VALUE
_
CSI Enabled
_
Interface Stability Standard
_
MT-Level MT-Safe with exceptions
.TE
.sp
.LP
The \fBlocaleconv()\fR function can be used safely in multithreaded
applications, as long as \fBsetlocale\fR(3C) is not being called to change the
locale.
.SH SEE ALSO
.sp
.LP
.BR setlocale (3C),
.BR attributes (7),
.BR environ (7),
.BR standards (7)
|