LOCALECONV(3P)
๐ LOCALECONV ๐
okay bestie, welcome to localeconv(3P) โ this is the POSIX Programmer's Manual page for it, and it's giving "let me tell you what your locale is doing with numbers" energy. โจ
๐ธ PROLOG ๐ธ
okay so first things first, this manual page is part of the POSIX Programmer's Manual. Heads up tho: the Linux implementation of this interface may differ โ so if you're on Linux, go check the corresponding Linux manual page for the actual details of how Linux does it. Also possible: the interface just isn't implemented on Linux at all. ๐ญ So like, vibe check your platform first, iykyk.
๐ NAME ๐
localeconv โ return locale-specific information. yes queen, that's literally the whole job. ๐
โจ SYNOPSIS โจ
#include <locale.h>
struct lconv *localeconv(void);
that's it. no arguments. she takes nothing and gives you everything (about locale formatting). ๐ซถ
๐ฆ DESCRIPTION ๐ฆ
ngl bestie, the functionality described on this reference page is aligned with the ISO C standard. So if there's any conflict between the requirements described here and the ISO C standard โ that's unintentional, fr fr. This volume of POSIX.1โ2017 defers to the ISO C standard. periodt.
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, and 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, and any of which can be {CHAR_MAX} to indicate that the value is not available in the current locale.
The members include the following:
char *decimal_pointโ The radix character used to format non-monetary quantities.char *thousands_sepโ The character used to separate groups of digits before the decimal-point character in formatted non-monetary quantities.char *groupingโ A string whose elements taken as one-byte integer values indicate the size of each group of digits in formatted non-monetary quantities.char *int_curr_symbolโ 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:2001 standard. The fourth character (immediately preceding the null byte) is the character used to separate the international currency symbol from the monetary quantity.char *currency_symbolโ The local currency symbol applicable to the current locale.char *mon_decimal_pointโ The radix character used to format monetary quantities.char *mon_thousands_sepโ The separator for groups of digits before the decimal-point in formatted monetary quantities.char *mon_groupingโ A string whose elements taken as one-byte integer values indicate the size of each group of digits in formatted monetary quantities.char *positive_signโ The string used to indicate a non-negative valued formatted monetary quantity.char *negative_signโ The string used to indicate a negative valued formatted monetary quantity.char int_frac_digitsโ The number of fractional digits (those after the decimal-point) to be displayed in an internationally formatted monetary quantity.char frac_digitsโ The number of fractional digits (those after the decimal-point) to be displayed in a formatted monetary quantity.char p_cs_precedesโ Set to1if thecurrency_symbolprecedes the value for a non-negative formatted monetary quantity. Set to0if the symbol succeeds the value.char p_sep_by_spaceโ Set to a value indicating the separation of thecurrency_symbol, the sign string, and the value for a non-negative formatted monetary quantity.char n_cs_precedesโ Set to1if thecurrency_symbolprecedes the value for a negative formatted monetary quantity. Set to0if the symbol succeeds the value.char n_sep_by_spaceโ Set to a value indicating the separation of thecurrency_symbol, the sign string, and the value for a negative formatted monetary quantity.char p_sign_posnโ Set to a value indicating the positioning of thepositive_signfor a non-negative formatted monetary quantity.char n_sign_posnโ Set to a value indicating the positioning of thenegative_signfor a negative formatted monetary quantity.char int_p_cs_precedesโ Set to1or0if theint_curr_symbolrespectively precedes or succeeds the value for a non-negative internationally formatted monetary quantity.char int_n_cs_precedesโ Set to1or0if theint_curr_symbolrespectively precedes or succeeds the value for a negative internationally formatted monetary quantity.char int_p_sep_by_spaceโ Set to a value indicating the separation of theint_curr_symbol, the sign string, and the value for a non-negative internationally formatted monetary quantity.char int_n_sep_by_spaceโ Set to a value indicating the separation of theint_curr_symbol, the sign string, and the value for a negative internationally formatted monetary quantity.char int_p_sign_posnโ Set to a value indicating the positioning of thepositive_signfor a non-negative internationally formatted monetary quantity.char int_n_sign_posnโ Set to a value indicating the positioning of thenegative_signfor a negative internationally formatted monetary quantity.
The elements of grouping and mon_grouping are interpreted according to the following:
{CHAR_MAX}โ No further grouping is to be performed.0โ The previous element is to be repeatedly used for the remainder of the digits.- other โ 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.
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:
0โ No space separates the currency symbol and value.1โ 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.2โ If the currency symbol and sign string are adjacent, a space separates them; otherwise, a space separates the sign string from the value.
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:
0โ Parentheses surround the quantity andcurrency_symbolorint_curr_symbol.1โ The sign string precedes the quantity andcurrency_symbolorint_curr_symbol.2โ The sign string succeeds the quantity andcurrency_symbolorint_curr_symbol.3โ The sign string immediately precedes thecurrency_symbolorint_curr_symbol.4โ The sign string immediately succeeds thecurrency_symbolorint_curr_symbol.
The implementation shall behave as if no function in this volume of POSIX.1โ2017 calls localeconv().
๐จ bestie important note: the localeconv() function need not be thread-safe. not me being a little chaotic about threads, but there it is. ๐
๐ RETURN VALUE ๐
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. Like, hands off, okay? ๐
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. ๐ญ
fr fr: don't hold onto that pointer like it's forever. it's giving "situationship," not "soulmate." ๐
โญ ERRORS โญ
No errors are defined. iconic behavior honestly, she simply doesn't fail. โจ
The following sections are informative.
๐ EXAMPLES ๐
None.
okay bestie that's where part 1 wraps up โ more parts coming, don't go anywhere ๐ซถ
๐ธ APPLICATION USAGE ๐ธ
okay bestie, this is the part where it all clicks into place โจ. Here's a lil illustration of the rules that four countries might use to format monetary quantities ๐
- Italy โ positive format
โฌ.1.230, negative format-โฌ.1.230, international formatEUR.1.230 - Netherlands โ positive format
โฌ 1.234,56, negative formatโฌ -1.234,56, international formatEUR 1.234,56 - Norway โ positive format
kr1.234,56, negative formatkr1.234,56-, international formatNOK 1.234,56 - Switzerland โ positive format
SFrs.1,234.56, negative formatSFrs.1,234.56C, international formatCHF 1,234.56
and for these same four countries, the monetary members of the struct that localeconv() hands back to you are exactly this ๐ซถ
int_curr_symbolโ Italy"EUR.", Netherlands"EUR ", Norway"NOK ", Switzerland"CHF "(yep, those trailing spaces are real, no cap, don't @ me)currency_symbolโ Italy"โฌ.", Netherlands"โฌ", Norway"kr", Switzerland"SFrs."mon_decimal_pointโ Italy"", Netherlands",", Norway",", Switzerland"."mon_thousands_sepโ Italy".", Netherlands".", Norway".", Switzerland","mon_groupingโ Italy"\3", Netherlands"\3", Norway"\3", Switzerland"\3"positive_signโ Italy"", Netherlands"", Norway"", Switzerland""negative_signโ Italy"-", Netherlands"-", Norway"-", Switzerland"C"int_frac_digitsโ Italy0, Netherlands2, Norway2, Switzerland2frac_digitsโ Italy0, Netherlands2, Norway2, Switzerland2p_cs_precedesโ Italy1, Netherlands1, Norway1, Switzerland1p_sep_by_spaceโ Italy0, Netherlands1, Norway0, Switzerland0n_cs_precedesโ Italy1, Netherlands1, Norway1, Switzerland1n_sep_by_spaceโ Italy0, Netherlands1, Norway0, Switzerland0p_sign_posnโ Italy1, Netherlands1, Norway1, Switzerland1n_sign_posnโ Italy1, Netherlands4, Norway2, Switzerland2int_p_cs_precedesโ Italy1, Netherlands1, Norway1, Switzerland1int_n_cs_precedesโ Italy1, Netherlands1, Norway1, Switzerland1int_p_sep_by_spaceโ Italy0, Netherlands0, Norway0, Switzerland0int_n_sep_by_spaceโ Italy0, Netherlands0, Norway0, Switzerland0int_p_sign_posnโ Italy1, Netherlands1, Norway1, Switzerland1int_n_sign_posnโ Italy1, Netherlands4, Norway4, Switzerland2
๐ค RATIONALE ๐ค
None.
like... none. that's the whole rationale. the reasoning is simply that there isn't one. iconic behaviour honestly ๐
๐ฎ FUTURE DIRECTIONS ๐ฎ
None.
also none bestie, the future is a mystery and this page is not about to speculate ๐ธ
๐ SEE ALSO ๐
go read these too, they're all part of the same friend group fr fr:
fprintf()fscanf()isalpha()isascii()nl_langinfo()setlocale()strcat()strchr()strcmp()strcoll()strcpy()strftime()strlen()strpbrk()strspn()strtok()strxfrm()strtod()uselocale()
and also, from the Base Definitions volume of POSIX.1โ2017:
<langinfo.h><locale.h>
๐ COPYRIGHT ๐
Some of this text has been 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. ๐
heads up bestie: if this version and the original IEEE and The Open Group Standard ever disagree about something, the original is the referee document. that's the final boss, no arguments. You can get the original Standard online at http://www.opengroup.org/unix/online.html .
And any typographical or formatting errors you spot on this page were most likely introduced during the conversion of the source files into man page format ๐. To report errors like that, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
and that's the whole page, bestie!! brought to you by IEEE/The Open Group, dated 2017, living under the name LOCALECONV(3P) ๐โจ go format some currency and slay ๐๐ฆ
๐ฆ where this page comes from
- alpine 3.22: man-pages-posix 2017a-r0 ยท custom
- alpine 3.23: man-pages-posix 2017a-r0 ยท custom
- alpine 3.24: man-pages-posix 2017a-r0 ยท custom
- arch rolling: man-pages 6.19-1
- arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages-posix 2017a
- opensuse-leap 16.0: man-pages-posix 2017a-160000.4.1 ยท SUSE-IEEE
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms