xref: /minix3/lib/libc/stdlib/strfmon.3 (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc.\"	$NetBSD: strfmon.3,v 1.5 2014/03/18 18:20:37 riastradh Exp $
22fe8fb19SBen Gras.\"
32fe8fb19SBen Gras.\" Copyright (c) 2001 Jeroen Ruigrok van der Werven <asmodai@FreeBSD.org>
42fe8fb19SBen Gras.\" All rights reserved.
52fe8fb19SBen Gras.\"
62fe8fb19SBen Gras.\" Redistribution and use in source and binary forms, with or without
72fe8fb19SBen Gras.\" modification, are permitted provided that the following conditions
82fe8fb19SBen Gras.\" are met:
92fe8fb19SBen Gras.\" 1. Redistributions of source code must retain the above copyright
102fe8fb19SBen Gras.\"    notice, this list of conditions and the following disclaimer.
112fe8fb19SBen Gras.\" 2. Redistributions in binary form must reproduce the above copyright
122fe8fb19SBen Gras.\"    notice, this list of conditions and the following disclaimer in the
132fe8fb19SBen Gras.\"    documentation and/or other materials provided with the distribution.
142fe8fb19SBen Gras.\"
152fe8fb19SBen Gras.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
162fe8fb19SBen Gras.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
172fe8fb19SBen Gras.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
182fe8fb19SBen Gras.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
192fe8fb19SBen Gras.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
202fe8fb19SBen Gras.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
212fe8fb19SBen Gras.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
222fe8fb19SBen Gras.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
232fe8fb19SBen Gras.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
242fe8fb19SBen Gras.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
252fe8fb19SBen Gras.\" SUCH DAMAGE.
262fe8fb19SBen Gras.\"
272fe8fb19SBen Gras.\" 	From: FreeBSD: Id: strfmon.3,v 1.7 2003/01/06 06:21:25 tjr Exp
282fe8fb19SBen Gras.\"
292fe8fb19SBen Gras.Dd October 12, 2002
302fe8fb19SBen Gras.Dt STRFMON 3
312fe8fb19SBen Gras.Os
322fe8fb19SBen Gras.Sh NAME
332fe8fb19SBen Gras.Nm strfmon
342fe8fb19SBen Gras.Nd convert monetary value to string
352fe8fb19SBen Gras.Sh LIBRARY
362fe8fb19SBen Gras.Lb libc
372fe8fb19SBen Gras.Sh SYNOPSIS
382fe8fb19SBen Gras.In monetary.h
392fe8fb19SBen Gras.Ft ssize_t
402fe8fb19SBen Gras.Fn strfmon "char * restrict s" "size_t maxsize" "const char * restrict format" "..."
412fe8fb19SBen Gras.Sh DESCRIPTION
422fe8fb19SBen GrasThe
432fe8fb19SBen Gras.Fn strfmon
442fe8fb19SBen Grasfunction places characters into the array pointed to by
452fe8fb19SBen Gras.Fa s
462fe8fb19SBen Grasas controlled by the string pointed to by
472fe8fb19SBen Gras.Fa format .
482fe8fb19SBen GrasNo more than
492fe8fb19SBen Gras.Fa maxsize
502fe8fb19SBen Grasbytes are placed into the array.
512fe8fb19SBen Gras.Pp
522fe8fb19SBen GrasThe format string is composed of zero or more directives:
532fe8fb19SBen Grasordinary characters (not
542fe8fb19SBen Gras.Cm % ) ,
552fe8fb19SBen Graswhich are copied unchanged to the output stream; and conversion
562fe8fb19SBen Grasspecifications, each of which results in fetching zero or more subsequent
572fe8fb19SBen Grasarguments.
582fe8fb19SBen GrasEach conversion specification is introduced by the
592fe8fb19SBen Gras.Cm %
602fe8fb19SBen Grascharacter.
612fe8fb19SBen GrasAfter the
622fe8fb19SBen Gras.Cm % ,
632fe8fb19SBen Grasthe following appear in sequence:
642fe8fb19SBen Gras.Bl -bullet
652fe8fb19SBen Gras.It
662fe8fb19SBen GrasZero or more of the following flags:
672fe8fb19SBen Gras.Bl -tag -width "XXX"
682fe8fb19SBen Gras.It Cm = Ns Ar f
692fe8fb19SBen GrasA
702fe8fb19SBen Gras.Sq Cm =
712fe8fb19SBen Grascharacter followed by another character
722fe8fb19SBen Gras.Ar f
732fe8fb19SBen Graswhich is used as the numeric fill character.
742fe8fb19SBen Gras.It Cm ^
752fe8fb19SBen GrasDo not use grouping characters, regardless of the current locale default.
762fe8fb19SBen Gras.It Cm +
772fe8fb19SBen GrasRepresent positive values by prefixing them with a positive sign,
782fe8fb19SBen Grasand negative values by prefixing them with a negative sign.
792fe8fb19SBen GrasThis is the default.
802fe8fb19SBen Gras.It Cm \&(
812fe8fb19SBen GrasEnclose negative values in parentheses.
822fe8fb19SBen Gras.It Cm \&!
832fe8fb19SBen GrasDo not include a currency symbol in the output.
842fe8fb19SBen Gras.It Cm \-
852fe8fb19SBen GrasLeft justify the result.
862fe8fb19SBen GrasOnly valid when a field width is specified.
872fe8fb19SBen Gras.El
882fe8fb19SBen Gras.It
892fe8fb19SBen GrasAn optional minimum field width as a decimal number.
902fe8fb19SBen GrasBy default, there is no minimum width.
912fe8fb19SBen Gras.It
922fe8fb19SBen GrasA
932fe8fb19SBen Gras.Sq Cm #
942fe8fb19SBen Grassign followed by a decimal number specifying the maximum
952fe8fb19SBen Grasexpected number of digits after the radix character.
962fe8fb19SBen Gras.It
972fe8fb19SBen GrasA
982fe8fb19SBen Gras.Sq Cm \&.
992fe8fb19SBen Grascharacter followed by a decimal number specifying the number
1002fe8fb19SBen Grasof digits after the radix character.
1012fe8fb19SBen Gras.It
1022fe8fb19SBen GrasOne of the following conversion specifiers:
1032fe8fb19SBen Gras.Bl -tag -width "XXX"
1042fe8fb19SBen Gras.It Cm i
1052fe8fb19SBen GrasThe
1062fe8fb19SBen Gras.Vt double
1072fe8fb19SBen Grasargument is formatted as an international monetary amount.
1082fe8fb19SBen Gras.It Cm n
1092fe8fb19SBen GrasThe
1102fe8fb19SBen Gras.Vt double
1112fe8fb19SBen Grasargument is formatted as a national monetary amount.
1122fe8fb19SBen Gras.It Cm %
1132fe8fb19SBen GrasA
1142fe8fb19SBen Gras.Sq Li %
1152fe8fb19SBen Grascharacter is written.
1162fe8fb19SBen Gras.El
1172fe8fb19SBen Gras.El
1182fe8fb19SBen Gras.Sh RETURN VALUES
1192fe8fb19SBen GrasIf the total number of resulting bytes including the terminating
1202fe8fb19SBen Gras.Dv NULL
1212fe8fb19SBen Grasbyte is not more than
1222fe8fb19SBen Gras.Fa maxsize ,
1232fe8fb19SBen Gras.Fn strfmon
1242fe8fb19SBen Grasreturns the number of bytes placed into the array pointed to by
1252fe8fb19SBen Gras.Fa s ,
1262fe8fb19SBen Grasnot including the terminating
1272fe8fb19SBen Gras.Dv NULL
1282fe8fb19SBen Grasbyte.
1292fe8fb19SBen GrasOtherwise, \-1 is returned,
1302fe8fb19SBen Grasthe contents of the array are indeterminate,
1312fe8fb19SBen Grasand
1322fe8fb19SBen Gras.Va errno
1332fe8fb19SBen Grasis set to indicate the error.
1342fe8fb19SBen Gras.Sh ERRORS
1352fe8fb19SBen GrasThe
1362fe8fb19SBen Gras.Fn strfmon
1372fe8fb19SBen Grasfunction will fail if:
1382fe8fb19SBen Gras.Bl -tag -width Er
1392fe8fb19SBen Gras.It Bq Er E2BIG
1402fe8fb19SBen GrasConversion stopped due to lack of space in the buffer.
1412fe8fb19SBen Gras.It Bq Er EINVAL
1422fe8fb19SBen GrasThe format string is invalid.
1432fe8fb19SBen Gras.It Bq Er ENOMEM
1442fe8fb19SBen GrasNot enough memory for temporary buffers.
1452fe8fb19SBen Gras.El
1462fe8fb19SBen Gras.Sh SEE ALSO
1472fe8fb19SBen Gras.Xr localeconv 3
1482fe8fb19SBen Gras.Sh STANDARDS
1492fe8fb19SBen GrasThe
1502fe8fb19SBen Gras.Fn strfmon
1512fe8fb19SBen Grasfunction
1522fe8fb19SBen Grasconforms to
1532fe8fb19SBen Gras.St -p1003.1-2001 .
1542fe8fb19SBen Gras.Sh AUTHORS
1552fe8fb19SBen Gras.An -nosplit
1562fe8fb19SBen GrasThe
1572fe8fb19SBen Gras.Fn strfmon
1582fe8fb19SBen Grasfunction was implemented by
15984d9c625SLionel Sambuc.An Alexey Zelkin Aq Mt phantom@FreeBSD.org .
1602fe8fb19SBen Gras.Pp
1612fe8fb19SBen GrasThis manual page was written by
16284d9c625SLionel Sambuc.An Jeroen Ruigrok van der Werven Aq Mt asmodai@FreeBSD.org
1632fe8fb19SBen Grasbased on the standard's text.
1642fe8fb19SBen Gras.Sh BUGS
1652fe8fb19SBen GrasThe
1662fe8fb19SBen Gras.Fn strfmon
1672fe8fb19SBen Grasfunction does not correctly handle multibyte characters in the
1682fe8fb19SBen Gras.Fa format
1692fe8fb19SBen Grasargument.
170