1.\" $NetBSD: strfmon.3,v 1.7 2017/08/16 17:41:36 wiz 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 August 15, 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 after the radix character. 106.It 107A 108.Sq Cm \&. 109character followed by a decimal number specifying the number 110of digits after the radix character. 111.It 112One of the following conversion specifiers: 113.Bl -tag -width "XXX" 114.It Cm i 115The 116.Vt double 117argument is formatted as an international monetary amount. 118.It Cm n 119The 120.Vt double 121argument is formatted as a national monetary amount. 122.It Cm % 123A 124.Sq Li % 125character is written. 126.El 127.El 128.Sh RETURN VALUES 129If the total number of resulting bytes including the terminating 130.Dv NULL 131byte is not more than 132.Fa maxsize , 133.Fn strfmon 134returns the number of bytes placed into the array pointed to by 135.Fa s , 136not including the terminating 137.Dv NULL 138byte. 139Otherwise, \-1 is returned, 140the contents of the array are indeterminate, 141and 142.Va errno 143is set to indicate the error. 144.Sh ERRORS 145The 146.Fn strfmon 147function will fail if: 148.Bl -tag -width Er 149.It Bq Er E2BIG 150Conversion stopped due to lack of space in the buffer. 151.It Bq Er EINVAL 152The format string is invalid. 153.It Bq Er ENOMEM 154Not enough memory for temporary buffers. 155.El 156.Sh SEE ALSO 157.Xr localeconv 3 158.Sh STANDARDS 159The 160.Fn strfmon 161function 162conforms to 163.St -p1003.1-2001 . 164.Sh AUTHORS 165.An -nosplit 166The 167.Fn strfmon 168function was implemented by 169.An Alexey Zelkin Aq Mt phantom@FreeBSD.org . 170.Pp 171This manual page was written by 172.An Jeroen Ruigrok van der Werven Aq Mt asmodai@FreeBSD.org 173based on the standard's text. 174.Sh BUGS 175The 176.Fn strfmon 177function does not correctly handle multibyte characters in the 178.Fa format 179argument. 180