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: head/lib/libc/stdlib/strfmon.3 237591 2012-06-26 05:34:31Z joel $ 26.\" 27.Dd November 17, 2013 28.Dt STRFMON 3 29.Os 30.Sh NAME 31.Nm strfmon , 32.Nm strfmon_l 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.In xlocale.h 41.Ft ssize_t 42.Fn strfmon_l "char * restrict s" "size_t maxsize" "locale_t loc" "const char * restrict format" "..." 43.Sh DESCRIPTION 44The 45.Fn strfmon 46function places characters into the array pointed to by 47.Fa s 48as controlled by the string pointed to by 49.Fa format . 50No more than 51.Fa maxsize 52bytes are placed into the array. 53.Pp 54The 55.Fn strfmon_l 56function does the same as 57.Fn strfmon 58but takes an explicit locale rather than using the current locale. 59.Pp 60The format string is composed of zero or more directives: 61ordinary characters (not 62.Cm % ) , 63which are copied unchanged to the output stream; and conversion 64specifications, each of which results in fetching zero or more subsequent 65arguments. 66Each conversion specification is introduced by the 67.Cm % 68character. 69After the 70.Cm % , 71the following appear in sequence: 72.Bl -bullet 73.It 74Zero or more of the following flags: 75.Bl -tag -width "XXX" 76.It Cm = Ns Ar f 77A 78.Sq Cm = 79character followed by another character 80.Ar f 81which is used as the numeric fill character. 82.It Cm ^ 83Do not use grouping characters, regardless of the current locale default. 84.It Cm + 85Represent positive values by prefixing them with a positive sign, 86and negative values by prefixing them with a negative sign. 87This is the default. 88.It Cm \&( 89Enclose negative values in parentheses. 90.It Cm \&! 91Do not include a currency symbol in the output. 92.It Cm \- 93Left justify the result. 94Only valid when a field width is specified. 95.El 96.It 97An optional minimum field width as a decimal number. 98By default, there is no minimum width. 99.It 100A 101.Sq Cm # 102sign followed by a decimal number specifying the maximum 103expected number of digits after the radix character. 104.It 105A 106.Sq Cm \&. 107character followed by a decimal number specifying the number 108of digits after the radix character. 109.It 110One of the following conversion specifiers: 111.Bl -tag -width "XXX" 112.It Cm i 113The 114.Vt double 115argument is formatted as an international monetary amount. 116.It Cm n 117The 118.Vt double 119argument is formatted as a national monetary amount. 120.It Cm % 121A 122.Sq Li % 123character is written. 124.El 125.El 126.Sh RETURN VALUES 127If the total number of resulting bytes including the terminating 128.Dv NUL 129byte is not more than 130.Fa maxsize , 131.Fn strfmon 132returns the number of bytes placed into the array pointed to by 133.Fa s , 134not including the terminating 135.Dv NUL 136byte. 137Otherwise, \-1 is returned, 138the contents of the array are indeterminate, 139and 140.Va errno 141is set to indicate the error. 142.Pp 143The 144.Fn strfmon_l 145function returns the same values as 146.Fn strfmon . 147.Sh ERRORS 148The 149.Fn strfmon 150function will fail if: 151.Bl -tag -width Er 152.It Bq Er E2BIG 153Conversion stopped due to lack of space in the buffer. 154.It Bq Er EINVAL 155The format string is invalid. 156.It Bq Er ENOMEM 157Not enough memory for temporary buffers. 158.El 159.Sh SEE ALSO 160.Xr localeconv 3 161.Sh STANDARDS 162The 163.Fn strfmon 164function 165conforms to 166.St -p1003.1-2001 . 167The 168.Fn strfmon_l 169function conforms to 170.St -p1003.1-2008 . 171.Sh AUTHORS 172.An -nosplit 173The 174.Fn strfmon 175function was implemented by 176.An Alexey Zelkin Aq Mt phantom@FreeBSD.org . 177.Pp 178This manual page was written by 179.An Jeroen Ruigrok van der Werven Aq Mt asmodai@FreeBSD.org 180based on the standard's text. 181.Sh BUGS 182The 183.Fn strfmon 184function does not correctly handle multibyte characters in the 185.Fa format 186argument. 187