2 .\" Copyright (c) 2002, Sun Microsystems, Inc. All Rights Reserved.
3 .\" Copyright 1989 AT&T
4 .\" Portions Copyright (c) 2001, the Institute of Electrical and Electronics Engineers, Inc. and The Open Group. All Rights Reserved.
5 .\" 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
6 .\" http://www.opengroup.org/bookstore/.
7 .\" 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 Sun OS 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.
8 .\" This notice shall appear on any product containing this material.
9 .\" 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.
10 .\" 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.
11 .\" 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]
12 .TH LOCALECONV 3C "Dec 12, 2003"
14 localeconv \- get numeric formatting information
20 \fBstruct lconv *\fR\fBlocaleconv\fR(\fBvoid\fR);
26 The \fBlocaleconv()\fR function sets the components of an object with type
27 \fBstruct lconv\fR (defined in \fB<locale.h>\fR) with the values appropriate
28 for the formatting of numeric quantities (monetary and otherwise) according to
29 the rules of the current locale (see \fBsetlocale\fR(3C)). The definition of
30 \fBstruct lconv\fR is given below (the values for the fields in the "C" locale
31 are given in comments).
35 char *decimal_point; /* "." */
36 char *thousands_sep; /* "" (zero length string) */
37 char *grouping; /* "" */
38 char *int_curr_symbol; /* "" */
39 char *currency_symbol; /* "" */
40 char *mon_decimal_point; /* "" */
41 char *mon_thousands_sep; /* "" */
42 char *mon_grouping; /* "" */
43 char *positive_sign; /* "" */
44 char *negative_sign; /* "" */
45 char int_frac_digits; /* CHAR_MAX */
46 char frac_digits; /* CHAR_MAX */
47 char p_cs_precedes; /* CHAR_MAX */
48 char p_sep_by_space; /* CHAR_MAX */
49 char n_cs_precedes; /* CHAR_MAX */
50 char n_sep_by_space; /* CHAR_MAX */
51 char p_sign_posn; /* CHAR_MAX*/
52 char n_sign_posn; /* CHAR_MAX */
58 The following members are also available to SUSv3-conforming applications. See
63 char int_p_cs_precedes; /* CHAR_MAX */
64 char int_p_sep_by_space; /* CHAR_MAX */
65 char int_n_cs_precedes; /* CHAR_MAX */
66 char int_n_sep_by_space; /* CHAR_MAX */
67 char int_p_sign_posn; /* CHAR_MAX */
68 char int_n_sign_posn; /* CHAR_MAX */
74 The members of the structure with type \fBchar *\fR are strings, any of which
75 (except \fBdecimal_point\fR) can point to a null string (""), to indicate that
76 the value is not available in the current locale or is of zero length. The
77 members with type \fBchar\fR are non-negative numbers, any of which can be
78 \fBCHAR_MAX\fR (defined in the \fB<limits.h>\fR header) to indicate that the
79 value is not available in the current locale. The members are the following:
83 \fB\fBchar *decimal_point\fR\fR
86 The decimal-point character used to format non-monetary quantities.
92 \fB\fBchar *thousands_sep\fR\fR
95 The character used to separate groups of digits to the left of the
96 decimal-point character in formatted non-monetary quantities.
102 \fB\fBchar *grouping\fR\fR
105 A string whose elements taken as one-byte integer values indicate the size of
106 each group of digits in formatted non-monetary quantities.
112 \fB\fBchar *int_curr_symbol\fR\fR
115 The international currency symbol applicable to the current locale. The first
116 three characters contain the alphabetic international currency symbol in
117 accordance with those specified in the ISO 4217: 1995 standard. The fourth
118 character (immediately preceding the null byte) is the character used to
119 separate the international currency symbol from the monetary quantity.
125 \fB\fBchar *currency_symbol\fR\fR
128 The local currency symbol applicable to the current locale.
134 \fB\fBchar *mon_decimal_point\fR\fR
137 The decimal point used to format monetary quantities.
143 \fB\fBchar *mon_thousands_sep\fR\fR
146 The separator for groups of digits to the left of the decimal point in
147 formatted monetary quantities.
153 \fB\fBchar *mon_grouping\fR\fR
156 A string whose elements taken as one-byte integer values indicate the size of
157 each group of digits in formatted monetary quantities.
163 \fB\fBchar *positive_sign\fR\fR
166 The string used to indicate a non-negative-valued formatted monetary quantity.
172 \fB\fBchar *negative_sign\fR\fR
175 The string used to indicate a negative-valued formatted monetary quantity.
181 \fB\fBchar int_frac_digits\fR\fR
184 The number of fractional digits (those to the right of the decimal point) to be
185 displayed in an internationally formatted monetary quantity.
191 \fB\fBchar frac_digits\fR\fR
194 The number of fractional digits (those to the right of the decimal point) to be
195 displayed in a formatted monetary quantity.
201 \fB\fBchar p_cs_precedes\fR\fR
204 Set to 1 or 0 if the \fBcurrency_symbol\fR respectively precedes or succeeds
205 the value for a non-negative formatted monetary quantity.
211 \fB\fBchar p_sep_by_space\fR\fR
214 Set to 0 if no space separates the \fBcurrency_symbol\fR or
215 \fBint_curr_symbol\fR from the value for a non-negative formatted monetary
216 quantity. Set to 1 if a space separates the symbol from the value; and set to 2
217 if a space separates the symbol and the sign string, if adjacent.
223 \fB\fBchar n_cs_precedes\fR\fR
226 Set to 1 or 0 if the \fBcurrency_symbol\fR respectively precedes or succeeds
227 the value for a negative formatted monetary quantity.
233 \fB\fBchar n_sep_by_space\fR\fR
236 Set to 0 if no space separates the \fBcurrency_symbol\fR or
237 \fBint_curr_symbol\fR from the value for a negative formatted monetary
238 quantity. Set to 1 if a space separates the symbol from the value; and set to 2
239 if a space separates the symbol and the sign string, if adjacent.
245 \fB\fBchar p_sign_posn\fR\fR
248 Set to a value indicating the positioning of the \fBpositive_sign\fR for a
249 non-negative formatted monetary quantity.
255 \fB\fBchar n_sign_posn\fR\fR
258 Set to a value indicating the positioning of the \fBnegative_sign\fR for a
259 negative formatted monetary quantity.
265 \fB\fBchar int_p_cs_precedes\fR\fR
268 Set to 1 or 0 if the \fBint_curr_symbol\fR respectively precedes or succeeds
269 the value for a non-negative internationally formatted monetary quantity.
275 \fB\fBchar int_n_cs_precedes\fR\fR
278 Set to 1 or 0 if the \fBint_curr_symbol\fR respectively precedes or succeeds
279 the value for a negative internationally formatted monetary quantity.
285 \fB\fBchar int_p_sep_by_space\fR\fR
288 Set to a value indicating the separation of the \fBint_curr_symbol\fR, the sign
289 string, and the value for a non-negative internationally formatted monetary
296 \fB\fBchar int_n_sep_by_space\fR\fR
299 Set to a value indicating the separation of the \fBint_curr_symbol\fR, the sign
300 string, and the value for a negative internationally formatted monetary
307 \fB\fBchar int_p_sign_posn\fR\fR
310 Set to a value indicating the positioning of the \fBpositive_sign\fR for a
311 non-negative internationally formatted monetary quantity.
317 \fB\fBchar int_n_sign_posn\fR\fR
320 Set to a value indicating the positioning of the \fBnegative_sign\fR for a
321 negative internationally formatted monetary quantity.
326 The elements of \fBgrouping\fR and \fBmon_grouping\fR are interpreted according
331 \fB{\fBCHAR_MAX\fR}\fR
334 No further grouping is to be performed.
343 The previous element is to be repeatedly used for the remainder of the digits.
352 The integer value is the number of digits that comprise the current group. The
353 next element is examined to determine the size of the next group of digits
354 before the current group.
359 The values of \fBp_sep_by_space\fR, \fBn_sep_by_space\fR,
360 \fBint_p_sep_by_space\fR, and \fBint_n_sep_by_space\fR are interpreted
361 according to the following:
368 No space separates the currency symbol and value.
377 If the currency symbol and sign string are adjacent, a space separates them
378 from the value; otherwise, a space separates the currency symbol from the
388 If the currency symbol and sign string are adjacent, a space separates them;
389 otherwise, a space separates the sign string from the value.
394 In an SUSv3-conforming application, for \fBint_p_sep_by_space\fR and
395 \fBint_n_sep_by_space\fR, the fourth character of \fBint_curr_symbol\fR is used
399 The values of \fBp_sign_posn\fR, \fBn_sign_posn\fR, \fBint_p_sign_posn\fR, and
400 \fBint_n_sign_posn\fR are interpreted according to the following:
407 Parentheses surround the quantity and \fBcurrency_symbol\fR or
408 \fBint_curr_symbol\fR.
417 The sign string precedes the quantity and \fBcurrency_symbol\fR or
418 \fBint_curr_symbol\fR.
427 The sign string succeeds the quantity and \fBcurrency_symbol\fR or
428 \fBint_curr_symbol\fR.
437 The sign string immediately precedes the \fBcurrency_symbol\fR or
438 \fBint_curr_symbol\fR.
447 The sign string immediately succeeds the \fBcurrency_symbol\fR or
448 \fBint_curr_symbol\fR.
454 The \fBlocaleconv()\fR function returns a pointer to the filled-in object. The
455 structure pointed to by the return value may be overwritten by a subsequent
456 call to \fBlocaleconv()\fR.
459 \fBExample 1 \fRRules used by four countries to format monetary quantities.
462 The following table illustrates the rules used by four countries to format
471 \fBCountry\fR \fBPositive\fR \fBNegative\fR \fBInternational\fR
473 Italy (IT) L.1.234 \(miL.1.234 ITL.1.234
475 Netherlands (NE) F 1.234,56 F \(mi1.234,56 NLG 1.234,56
477 Norway (NO) kr1.234,56 kr1.234,56\(mi NOK 1.234,56
479 Switzerland (SW) SFrs.1,234.56 SFrs.1,234.56C CHF 1,234.56
484 For these four countries, the respective values for the monetary members of the
485 structure returned by \fBlocaleconv()\fR are as follows:
493 \fBIT\fR \fBNE\fR \fBNO\fR \fBSW\fR
494 \fBint_curr_symbol\fR "ITL." "NLG " "NOK " "CHF "
495 \fBcurrency_symbol\fR "L." "F" "kr" "SFrs."
496 \fBmon_decimal_point\fR "" "," "," "."
497 \fBmon_thousands_sep\fR "." "." "." ","
498 \fBmon_grouping\fR "\e3" "\e3" "\e3" "\e3"
499 \fBpositive_sign\fR "" "" "" ""
500 \fBnegative_sign\fR "-" "-" "-" "C"
501 \fBint_frac_digits\fR 0 2 2 2
502 \fBfrac_digits\fR 0 2 2 2
503 \fBp_cs_precedes\fR 1 1 1 1
504 \fBp_sep_by_space\fR 0 1 0 0
505 \fBn_cs_precedes\fR 1 1 1 1
506 \fBn_sep_by_space\fR 0 1 0 0
507 \fBp_sign_posn\fR 1 1 1 1
508 \fBn_sign_posn\fR 1 4 2 2
509 \fBint_p_cs_precedes\fR 1 1 1 1
510 \fBint_n_cs_precedes\fR 1 1 1 1
511 \fBint_p_sep_by_space\fR 0 0 0 0
512 \fBint_n_sep_by_space\fR 0 0 0 0
513 \fBint_p_sign_posn\fR 1 1 1 1
514 \fBint_n_sign_posn\fR 1 4 4 2
520 See \fBattributes\fR(5) for descriptions of the following attributes:
528 ATTRIBUTE TYPE ATTRIBUTE VALUE
532 Interface Stability Standard
534 MT-Level MT-Safe with exceptions
539 The \fBlocaleconv()\fR function can be used safely in multithreaded
540 applications, as long as \fBsetlocale\fR(3C) is not being called to change the
545 \fBsetlocale\fR(3C), \fBattributes\fR(5), \fBenviron\fR(5), \fBstandards\fR(5)