LOCALECONV(3POSIX) | POSIX Programmer's Manual | LOCALECONV(3POSIX) |
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.
localeconv — return locale-specific information
#include <locale.h>
struct lconv *localeconv(void);
The functionality described on this reference page is aligned with the ISO C standard. Any conflict between the requirements described here and the ISO C standard is unintentional. This volume of POSIX.1‐2017 defers to the ISO C standard.
The localeconv() function shall set the components of an object with the type struct lconv with the values appropriate for the formatting of numeric quantities (monetary and otherwise) according to the rules of the current locale.
The members of the structure with type char * are pointers to strings, any of which (except decimal_point) can point to "", to indicate that the value is not available in the current locale or is of zero length. The members with type char are non-negative numbers, any of which can be {CHAR_MAX} to indicate that the value is not available in the current locale.
The members include the following:
The elements of grouping and mon_grouping are interpreted according to the following:
The values of p_sep_by_space, n_sep_by_space, int_p_sep_by_space, and int_n_sep_by_space are interpreted according to the following:
For int_p_sep_by_space and int_n_sep_by_space, the fourth character of int_curr_symbol is used instead of a space.
The values of p_sign_posn, n_sign_posn, int_p_sign_posn, and int_n_sign_posn are interpreted according to the following:
The implementation shall behave as if no function in this volume of POSIX.1‐2017 calls localeconv().
The localeconv() function need not be thread-safe.
The localeconv() function shall return a pointer to the filled-in object. The application shall not modify the structure to which the return value points, nor any storage areas pointed to by pointers within the structure. The returned pointer, and pointers within the structure, might be invalidated or the structure or the storage areas might be overwritten by a subsequent call to localeconv(). In addition, the returned pointer, and pointers within the structure, might be invalidated or the structure or the storage areas might be overwritten by subsequent calls to setlocale() with the categories LC_ALL, LC_MONETARY, or LC_NUMERIC, or by calls to uselocale() which change the categories LC_MONETARY or LC_NUMERIC. The returned pointer, pointers within the structure, the structure, and the storage areas might also be invalidated if the calling thread is terminated.
No errors are defined.
The following sections are informative.
None.
The following table illustrates the rules which may be used by four countries to format monetary quantities.
Country | Positive Format | Negative Format | International Format |
Italy | €.1.230 | -€.1.230 | EUR.1.230 |
Netherlands | € 1.234,56 | € -1.234,56 | EUR 1.234,56 |
Norway | kr1.234,56 | kr1.234,56- | NOK 1.234,56 |
Switzerland | SFrs.1,234.56 | SFrs.1,234.56C | CHF 1,234.56 |
For these four countries, the respective values for the monetary members of the structure returned by localeconv() are:
Italy | Netherlands | Norway | Switzerland | |
int_curr_symbol | "EUR." | "EUR " | "NOK " | "CHF " |
currency_symbol | "€." | "€" | "kr" | "SFrs." |
mon_decimal_point | "" | "," | "," | "." |
mon_thousands_sep | "." | "." | "." | "," |
mon_grouping | "\3" | "\3" | "\3" | "\3" |
positive_sign | "" | "" | "" | "" |
negative_sign | "-" | "-" | "-" | "C" |
int_frac_digits | 0 | 2 | 2 | 2 |
frac_digits | 0 | 2 | 2 | 2 |
p_cs_precedes | 1 | 1 | 1 | 1 |
p_sep_by_space | 0 | 1 | 0 | 0 |
n_cs_precedes | 1 | 1 | 1 | 1 |
n_sep_by_space | 0 | 1 | 0 | 0 |
p_sign_posn | 1 | 1 | 1 | 1 |
n_sign_posn | 1 | 4 | 2 | 2 |
int_p_cs_precedes | 1 | 1 | 1 | 1 |
int_n_cs_precedes | 1 | 1 | 1 | 1 |
int_p_sep_by_space | 0 | 0 | 0 | 0 |
int_n_sep_by_space | 0 | 0 | 0 | 0 |
int_p_sign_posn | 1 | 1 | 1 | 1 |
int_n_sign_posn | 1 | 4 | 4 | 2 |
None.
None.
fprintf(), fscanf(), isalpha(), isascii(), nl_langinfo(), setlocale(), strcat(), strchr(), strcmp(), strcoll(), strcpy(), strftime(), strlen(), strpbrk(), strspn(), strtok(), strxfrm(), strtod(), uselocale()
The Base Definitions volume of POSIX.1‐2017, <langinfo.h>, <locale.h>
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version 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 .
Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
2017 | IEEE/The Open Group |