311 lines
6.6 KiB
HTML
311 lines
6.6 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of STRFMON</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>STRFMON</H1>
|
|
Section: Linux Programmer's Manual (3)<BR>Updated: 2017-09-15<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
strfmon, strfmon_l - convert monetary value to a string
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
<PRE>
|
|
<B>#include <<A HREF="file:///usr/include/monetary.h">monetary.h</A>></B>
|
|
|
|
<B>ssize_t strfmon(char *</B><I>s</I><B>, size_t </B><I>max</I><B>, const char *</B><I>format</I><B>,</B>
|
|
<B>...);</B>
|
|
|
|
<B>ssize_t strfmon_l(char *</B><I>s</I><B>, size_t </B><I>max</I><B>, locale_t </B><I>locale</I><B>,</B>
|
|
<B>const char * format , ...);</B>
|
|
</PRE>
|
|
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
The
|
|
<B>strfmon</B>()
|
|
|
|
function formats the specified monetary amount
|
|
according to the current locale
|
|
and format specification
|
|
<I>format</I>
|
|
|
|
and places the
|
|
result in the character array
|
|
<I>s</I>
|
|
|
|
of size
|
|
<I>max</I>.
|
|
|
|
<P>
|
|
|
|
The
|
|
<B>strfmon_l</B>()
|
|
|
|
function performs the same task,
|
|
but uses
|
|
the locale specified by
|
|
<I>locale</I>.
|
|
|
|
The behavior of
|
|
<B>strfmon_l</B>()
|
|
|
|
is undefined if
|
|
<I>locale</I>
|
|
|
|
is the special locale object
|
|
<B>LC_GLOBAL_LOCALE</B>
|
|
|
|
(see
|
|
<B><A HREF="/cgi-bin/man/man2html?3+duplocale">duplocale</A></B>(3))
|
|
|
|
or is not a valid locale object handle.
|
|
<P>
|
|
|
|
Ordinary characters in
|
|
<I>format</I>
|
|
|
|
are copied to
|
|
<I>s</I>
|
|
|
|
without conversion.
|
|
Conversion specifiers are introduced by a '%'
|
|
character.
|
|
Immediately following it there can be zero or more
|
|
of the following flags:
|
|
<DL COMPACT>
|
|
<DT id="1"><B>=</B><I>f</I>
|
|
|
|
<DD>
|
|
The single-byte character
|
|
<I>f</I>
|
|
|
|
is used as the numeric fill character (to be used with
|
|
a left precision, see below).
|
|
When not specified, the space character is used.
|
|
<DT id="2"><B>^</B>
|
|
|
|
<DD>
|
|
Do not use any grouping characters that might be defined
|
|
for the current locale.
|
|
By default, grouping is enabled.
|
|
<DT id="3"><B>(</B> or <B>+</B>
|
|
|
|
<DD>
|
|
The ( flag indicates that negative amounts should be enclosed between
|
|
parentheses.
|
|
The + flag indicates that signs should be handled
|
|
in the default way, that is, amounts are preceded by the locale's
|
|
sign indication, for example, nothing for positive, "-" for negative.
|
|
<DT id="4"><B>!</B>
|
|
|
|
<DD>
|
|
Omit the currency symbol.
|
|
<DT id="5"><B>-</B>
|
|
|
|
<DD>
|
|
Left justify all fields.
|
|
The default is right justification.
|
|
</DL>
|
|
<P>
|
|
|
|
Next, there may be a field width: a decimal digit string specifying
|
|
a minimum field width in bytes.
|
|
The default is 0.
|
|
A result smaller than this width is padded with spaces
|
|
(on the left, unless the left-justify flag was given).
|
|
<P>
|
|
|
|
Next, there may be a left precision of the form "#" followed by
|
|
a decimal digit string.
|
|
If the number of digits left of the
|
|
radix character is smaller than this, the representation is
|
|
padded on the left with the numeric fill character.
|
|
Grouping characters are not counted in this field width.
|
|
<P>
|
|
|
|
Next, there may be a right precision of the form "." followed by
|
|
a decimal digit string.
|
|
The amount being formatted is rounded to
|
|
the specified number of digits prior to formatting.
|
|
The default is specified in the
|
|
<I>frac_digits</I>
|
|
|
|
and
|
|
<I>int_frac_digits</I>
|
|
|
|
items of the current locale.
|
|
If the right precision is 0, no radix character is printed.
|
|
(The radix character here is determined by
|
|
<B>LC_MONETARY</B>,
|
|
|
|
and may differ from that specified by
|
|
<B>LC_NUMERIC</B>.)
|
|
|
|
<P>
|
|
|
|
Finally, the conversion specification must be ended with a
|
|
conversion character.
|
|
The three conversion characters are
|
|
<DL COMPACT>
|
|
<DT id="6"><B>%</B>
|
|
|
|
<DD>
|
|
(In this case, the entire specification must be exactly "%%".)
|
|
Put a '%' character in the result string.
|
|
<DT id="7"><B>i</B>
|
|
|
|
<DD>
|
|
One argument of type
|
|
<I>double</I>
|
|
|
|
is converted using the locale's international currency format.
|
|
<DT id="8"><B>n</B>
|
|
|
|
<DD>
|
|
One argument of type
|
|
<I>double</I>
|
|
|
|
is converted using the locale's national currency format.
|
|
</DL>
|
|
<A NAME="lbAE"> </A>
|
|
<H2>RETURN VALUE</H2>
|
|
|
|
The
|
|
<B>strfmon</B>()
|
|
|
|
function returns the number of characters placed
|
|
in the array
|
|
<I>s</I>,
|
|
|
|
not including the terminating null byte,
|
|
provided the string, including the terminating null byte, fits.
|
|
Otherwise, it sets
|
|
<I>errno</I>
|
|
|
|
to
|
|
<B>E2BIG</B>,
|
|
|
|
returns -1, and the contents of the array is undefined.
|
|
<A NAME="lbAF"> </A>
|
|
<H2>ATTRIBUTES</H2>
|
|
|
|
For an explanation of the terms used in this section, see
|
|
<B><A HREF="/cgi-bin/man/man2html?7+attributes">attributes</A></B>(7).
|
|
|
|
<TABLE BORDER>
|
|
<TR VALIGN=top><TD><B>Interface</B></TD><TD><B>Attribute</B></TD><TD><B>Value</B><BR></TD></TR>
|
|
<TR VALIGN=top><TD>
|
|
<B>strfmon</B>()
|
|
|
|
</TD><TD>Thread safety</TD><TD>MT-Safe locale<BR></TD></TR>
|
|
<TR VALIGN=top><TD>
|
|
<B>strfmon_l</B>()
|
|
|
|
</TD><TD>Thread safety</TD><TD>MT-Safe<BR></TD></TR>
|
|
</TABLE>
|
|
|
|
<P>
|
|
<A NAME="lbAG"> </A>
|
|
<H2>CONFORMING TO</H2>
|
|
|
|
POSIX.1-2001, POSIX.1-2008.
|
|
<A NAME="lbAH"> </A>
|
|
<H2>EXAMPLE</H2>
|
|
|
|
The call
|
|
<P>
|
|
|
|
|
|
|
|
strfmon(buf, sizeof(buf), "[%^=*#6n] [%=*#6i]",
|
|
<BR> 1234.567, 1234.567);
|
|
|
|
|
|
<P>
|
|
|
|
outputs
|
|
<P>
|
|
|
|
|
|
|
|
[€ **1234,57] [EUR **1 234,57]
|
|
|
|
|
|
<P>
|
|
|
|
in the
|
|
<I>nl_NL</I>
|
|
|
|
locale.
|
|
The
|
|
<I>de_DE</I>,
|
|
|
|
<I>de_CH</I>,
|
|
|
|
<I>en_AU</I>,
|
|
|
|
and
|
|
<I>en_GB</I>
|
|
|
|
locales yield
|
|
<P>
|
|
|
|
|
|
|
|
[ **1234,57 €] [ **1.234,57 EUR]
|
|
[ Fr. **1234.57] [ CHF **1'234.57]
|
|
[ $**1234.57] [ AUD**1,234.57]
|
|
[ £**1234.57] [ GBP**1,234.57]
|
|
|
|
|
|
<A NAME="lbAI"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+duplocale">duplocale</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+setlocale">setlocale</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+sprintf">sprintf</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?7+locale">locale</A></B>(7)
|
|
|
|
<A NAME="lbAJ"> </A>
|
|
<H2>COLOPHON</H2>
|
|
|
|
This page is part of release 5.05 of the Linux
|
|
<I>man-pages</I>
|
|
|
|
project.
|
|
A description of the project,
|
|
information about reporting bugs,
|
|
and the latest version of this page,
|
|
can be found at
|
|
<A HREF="https://www.kernel.org/doc/man-pages/.">https://www.kernel.org/doc/man-pages/.</A>
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="9"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="10"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="11"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="12"><A HREF="#lbAE">RETURN VALUE</A><DD>
|
|
<DT id="13"><A HREF="#lbAF">ATTRIBUTES</A><DD>
|
|
<DT id="14"><A HREF="#lbAG">CONFORMING TO</A><DD>
|
|
<DT id="15"><A HREF="#lbAH">EXAMPLE</A><DD>
|
|
<DT id="16"><A HREF="#lbAI">SEE ALSO</A><DD>
|
|
<DT id="17"><A HREF="#lbAJ">COLOPHON</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:58 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|