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