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