These members of the struct lconv
structure specify how to print the symbol to identify a monetary value---the international analog of `$' for US dollars.
Each country has two standard currency symbols. The local currency symbol is used commonly within the country, while the international currency symbol is used internationally to refer to that country's currency when it is necessary to indicate the country unambiguously.
For example, many countries use the dollar as their monetary unit, and when dealing with international currencies it's important to specify that one is dealing with (say) Canadian dollars instead of U.S. dollars or Australian dollars. But when the context is known to be Canada, there is no need to make this explicit---dollar amounts are implicitly assumed to be in Canadian dollars.
char *currency_symbol
In the standard `C' locale, this member has a value of ""
(the empty string), meaning ``unspecified''. The ANSI standard doesn't say what to do when you find this value; we recommend you simply print the empty string as you would print any other string found in the appropriate member.
char *int_curr_symbol
The value of int_curr_symbol
should normally consist of a three-letter abbreviation determined by the international standard ISO 4217 Codes for the Representation of Currency and Funds, followed by a one-character separator (often a space).
In the standard `C' locale, this member has a value of ""
(the empty string), meaning ``unspecified''. We recommend you simply print the empty string as you would print any other string found in the appropriate member.
char p_cs_precedes
char n_cs_precedes
1
if the currency_symbol
string should precede the value of a monetary amount, or 0
if the string should follow the value. The p_cs_precedes
member applies to positive amounts (or zero), and the n_cs_precedes
member applies to negative amounts.
In the standard `C' locale, both of these members have a value of CHAR_MAX
, meaning ``unspecified''. The ANSI standard doesn't say what to do when you find this value, but we recommend printing the currency symbol before the amount. That's right for most countries. In other words, treat all nonzero values alike in these members.
The POSIX standard says that these two members apply to the int_curr_symbol
as well as the currency_symbol
. The ANSI C standard seems to imply that they should apply only to the currency_symbol
---so the int_curr_symbol
should always precede the amount.
We can only guess which of these (if either) matches the usual conventions for printing international currency symbols. Our guess is that they should always preceed the amount. If we find out a reliable answer, we will put it here.
char p_sep_by_space
char n_sep_by_space
1
if a space should appear between the currency_symbol
string and the amount, or 0
if no space should appear. The p_sep_by_space
member applies to positive amounts (or zero), and the n_sep_by_space
member applies to negative amounts.
In the standard `C' locale, both of these members have a value of CHAR_MAX
, meaning ``unspecified''. The ANSI standard doesn't say what you should do when you find this value; we suggest you treat it as one (print a space). In other words, treat all nonzero values alike in these members.
These members apply only to currency_symbol
. When you use int_curr_symbol
, you never print an additional space, because int_curr_symbol
itself contains the appropriate separator.
The POSIX standard says that these two members apply to the int_curr_symbol
as well as the currency_symbol
. But an example in the ANSI C standard clearly implies that they should apply only to the currency_symbol
---that the int_curr_symbol
contains any appropriate separator, so you should never print an additional space.
Based on what we know now, we recommend you ignore these members when printing international currency symbols, and print no extra space.