1.\" Copyright (c) 2001 Jeroen Ruigrok van der Werven <asmodai@FreeBSD.org> 2.\" All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer. 9.\" 2. Redistributions in binary form must reproduce the above copyright 10.\" notice, this list of conditions and the following disclaimer in the 11.\" documentation and/or other materials provided with the distribution. 12.\" 13.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 14.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 17.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23.\" SUCH DAMAGE. 24.\" 25.\" $FreeBSD: src/lib/libc/stdlib/strfmon.3,v 1.7 2003/01/06 06:21:25 tjr Exp $ 26.\" $NetBSD: strfmon.3,v 1.3 2005/04/04 08:19:00 wiz Exp $ 27.\" 28.Dd October 6, 2008 29.Dt STRFMON 3 30.Os 31.Sh NAME 32.Nm strfmon 33.Nd convert monetary value to string 34.Sh LIBRARY 35.Lb libc 36.Sh SYNOPSIS 37.In monetary.h 38.Ft ssize_t 39.Fn strfmon "char * restrict s" "size_t maxsize" "const char * restrict format" "..." 40.Sh DESCRIPTION 41The 42.Fn strfmon 43function places characters into the array pointed to by 44.Fa s 45as controlled by the string pointed to by 46.Fa format . 47No more than 48.Fa maxsize 49bytes are placed into the array. 50.Pp 51The format string is composed of zero or more directives: 52ordinary characters (not 53.Cm % ) , 54which are copied unchanged to the output stream; and conversion 55specifications, each of which results in fetching zero or more subsequent 56arguments. 57Each conversion specification is introduced by the 58.Cm % 59character. 60After the 61.Cm % , 62the following appear in sequence: 63.Bl -bullet 64.It 65Zero or more of the following flags: 66.Bl -tag -width "XXX" 67.It Cm = Ns Ar f 68A 69.Sq Cm = 70character followed by another character 71.Ar f 72which is used as the numeric fill character. 73.It Cm ^ 74Do not use grouping characters, regardless of the current locale default. 75.It Cm + 76Represent positive values by prefixing them with a positive sign, 77and negative values by prefixing them with a negative sign. 78This is the default. 79.It Cm \&( 80Enclose negative values in parentheses. 81.It Cm \&! 82Do not include a currency symbol in the output. 83.It Cm \- 84Left justify the result. 85Only valid when a field width is specified. 86.El 87.It 88An optional minimum field width as a decimal number. 89By default, there is no minimum width. 90.It 91A 92.Sq Cm # 93sign followed by a decimal number specifying the maximum 94expected number of digits after the radix character. 95.It 96A 97.Sq Cm \&. 98character followed by a decimal number specifying the number 99of digits after the radix character. 100.It 101One of the following conversion specifiers: 102.Bl -tag -width "XXX" 103.It Cm i 104The 105.Vt double 106argument is formatted as an international monetary amount. 107.It Cm n 108The 109.Vt double 110argument is formatted as a national monetary amount. 111.It Cm % 112A 113.Sq Li % 114character is written. 115.El 116.El 117.Sh RETURN VALUES 118If the total number of resulting bytes including the terminating 119.Dv NULL 120byte is not more than 121.Fa maxsize , 122.Fn strfmon 123returns the number of bytes placed into the array pointed to by 124.Fa s , 125not including the terminating 126.Dv NULL 127byte. 128Otherwise, \-1 is returned, 129the contents of the array are indeterminate, 130and 131.Va errno 132is set to indicate the error. 133.Sh ERRORS 134The 135.Fn strfmon 136function will fail if: 137.Bl -tag -width Er 138.It Bq Er E2BIG 139Conversion stopped due to lack of space in the buffer. 140.It Bq Er EINVAL 141The format string is invalid. 142.It Bq Er ENOMEM 143Not enough memory for temporary buffers. 144.El 145.Sh SEE ALSO 146.Xr localeconv 3 147.Sh STANDARDS 148The 149.Fn strfmon 150function 151conforms to 152.St -p1003.1-2001 . 153.Sh AUTHORS 154.An -nosplit 155The 156.Fn strfmon 157function was implemented by 158.An Alexey Zelkin Aq Mt phantom@FreeBSD.org . 159.Pp 160This manual page was written by 161.An Jeroen Ruigrok van der Werven Aq Mt asmodai@FreeBSD.org 162based on the standard's text. 163.Sh BUGS 164The 165.Fn strfmon 166function does not correctly handle multibyte characters in the 167.Fa format 168argument. 169