xref: /freebsd/lib/libc/stdio/wprintf.3 (revision c5604d0a50cc18e7c5546e9c77a8fdcb69cb5e3c)
1c5604d0aSTim J. Robbins.\" Copyright (c) 1990, 1991, 1993
2c5604d0aSTim J. Robbins.\"	The Regents of the University of California.  All rights reserved.
3c5604d0aSTim J. Robbins.\"
4c5604d0aSTim J. Robbins.\" This code is derived from software contributed to Berkeley by
5c5604d0aSTim J. Robbins.\" Chris Torek and the American National Standards Committee X3,
6c5604d0aSTim J. Robbins.\" on Information Processing Systems.
7c5604d0aSTim J. Robbins.\"
8c5604d0aSTim J. Robbins.\" Redistribution and use in source and binary forms, with or without
9c5604d0aSTim J. Robbins.\" modification, are permitted provided that the following conditions
10c5604d0aSTim J. Robbins.\" are met:
11c5604d0aSTim J. Robbins.\" 1. Redistributions of source code must retain the above copyright
12c5604d0aSTim J. Robbins.\"    notice, this list of conditions and the following disclaimer.
13c5604d0aSTim J. Robbins.\" 2. Redistributions in binary form must reproduce the above copyright
14c5604d0aSTim J. Robbins.\"    notice, this list of conditions and the following disclaimer in the
15c5604d0aSTim J. Robbins.\"    documentation and/or other materials provided with the distribution.
16c5604d0aSTim J. Robbins.\" 3. All advertising materials mentioning features or use of this software
17c5604d0aSTim J. Robbins.\"    must display the following acknowledgement:
18c5604d0aSTim J. Robbins.\"	This product includes software developed by the University of
19c5604d0aSTim J. Robbins.\"	California, Berkeley and its contributors.
20c5604d0aSTim J. Robbins.\" 4. Neither the name of the University nor the names of its contributors
21c5604d0aSTim J. Robbins.\"    may be used to endorse or promote products derived from this software
22c5604d0aSTim J. Robbins.\"    without specific prior written permission.
23c5604d0aSTim J. Robbins.\"
24c5604d0aSTim J. Robbins.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25c5604d0aSTim J. Robbins.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26c5604d0aSTim J. Robbins.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27c5604d0aSTim J. Robbins.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28c5604d0aSTim J. Robbins.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29c5604d0aSTim J. Robbins.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30c5604d0aSTim J. Robbins.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31c5604d0aSTim J. Robbins.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32c5604d0aSTim J. Robbins.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33c5604d0aSTim J. Robbins.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34c5604d0aSTim J. Robbins.\" SUCH DAMAGE.
35c5604d0aSTim J. Robbins.\"
36c5604d0aSTim J. Robbins.\"     @(#)printf.3	8.1 (Berkeley) 6/4/93
37c5604d0aSTim J. Robbins.\" FreeBSD: src/lib/libc/stdio/printf.3,v 1.47 2002/09/06 11:23:55 tjr Exp
38c5604d0aSTim J. Robbins.\" $FreeBSD$
39c5604d0aSTim J. Robbins.\"
40c5604d0aSTim J. Robbins.Dd September 18, 2002
41c5604d0aSTim J. Robbins.Dt WPRINTF 3
42c5604d0aSTim J. Robbins.Os
43c5604d0aSTim J. Robbins.Sh NAME
44c5604d0aSTim J. Robbins.Nm wprintf , fwprintf , swprintf ,
45c5604d0aSTim J. Robbins.Nm vwprintf , vfwprintf , vswprintf
46c5604d0aSTim J. Robbins.Nd formatted wide character output conversion
47c5604d0aSTim J. Robbins.Sh LIBRARY
48c5604d0aSTim J. Robbins.Lb libc
49c5604d0aSTim J. Robbins.Sh SYNOPSIS
50c5604d0aSTim J. Robbins.In stdio.h
51c5604d0aSTim J. Robbins.In wchar.h
52c5604d0aSTim J. Robbins.Ft int
53c5604d0aSTim J. Robbins.Fn fwprintf "FILE * restrict stream" "const wchar_t * restrict format" ...
54c5604d0aSTim J. Robbins.Ft int
55c5604d0aSTim J. Robbins.Fn swprintf "wchar_t * restrict ws" "size_t n" "const wchar_t * restrict format" ...
56c5604d0aSTim J. Robbins.Ft int
57c5604d0aSTim J. Robbins.Fn wprintf "const wchar_t * restrict format" ...
58c5604d0aSTim J. Robbins.In stdarg.h
59c5604d0aSTim J. Robbins.Ft int
60c5604d0aSTim J. Robbins.Fn vfwprintf "FILE * restrict stream" "const wchar_t * restrict" "va_list ap"
61c5604d0aSTim J. Robbins.Ft int
62c5604d0aSTim J. Robbins.Fn vswprintf "wchar_t * restrict ws" "size_t n" "const wchar_t *restrict format" "va_list ap"
63c5604d0aSTim J. Robbins.Ft int
64c5604d0aSTim J. Robbins.Fn vwprintf "const wchar_t * restrict format" "va_list ap"
65c5604d0aSTim J. Robbins.Sh DESCRIPTION
66c5604d0aSTim J. RobbinsThe
67c5604d0aSTim J. Robbins.Fn wprintf
68c5604d0aSTim J. Robbinsfamily of functions produces output according to a
69c5604d0aSTim J. Robbins.Fa format
70c5604d0aSTim J. Robbinsas described below.
71c5604d0aSTim J. RobbinsThe
72c5604d0aSTim J. Robbins.Fn wprintf
73c5604d0aSTim J. Robbinsand
74c5604d0aSTim J. Robbins.Fn vwprintf
75c5604d0aSTim J. Robbinsfunctions
76c5604d0aSTim J. Robbinswrite output to
77c5604d0aSTim J. Robbins.Pa stdout ,
78c5604d0aSTim J. Robbinsthe standard output stream;
79c5604d0aSTim J. Robbins.Fn fwprintf
80c5604d0aSTim J. Robbinsand
81c5604d0aSTim J. Robbins.Fn vfwprintf
82c5604d0aSTim J. Robbinswrite output to the given output
83c5604d0aSTim J. Robbins.Fa stream ;
84c5604d0aSTim J. Robbins.Fn swprintf ,
85c5604d0aSTim J. Robbins.Fn vswprintf ,
86c5604d0aSTim J. Robbinsand
87c5604d0aSTim J. Robbins.Fn vsnprintf
88c5604d0aSTim J. Robbinswrite to the wide character string
89c5604d0aSTim J. Robbins.Fa ws .
90c5604d0aSTim J. Robbins.Pp
91c5604d0aSTim J. RobbinsThese functions write the output under the control of a
92c5604d0aSTim J. Robbins.Fa format
93c5604d0aSTim J. Robbinsstring that specifies how subsequent arguments
94c5604d0aSTim J. Robbins(or arguments accessed via the variable-length argument facilities of
95c5604d0aSTim J. Robbins.Xr stdarg 3 )
96c5604d0aSTim J. Robbinsare converted for output.
97c5604d0aSTim J. Robbins.Pp
98c5604d0aSTim J. RobbinsThese functions return the number of characters printed
99c5604d0aSTim J. Robbins(not including the trailing
100c5604d0aSTim J. Robbins.Ql \e0
101c5604d0aSTim J. Robbinsused to end output to strings).
102c5604d0aSTim J. Robbins.Pp
103c5604d0aSTim J. RobbinsThe
104c5604d0aSTim J. Robbins.Fn swprintf
105c5604d0aSTim J. Robbinsand
106c5604d0aSTim J. Robbins.Fn vswprintf
107c5604d0aSTim J. Robbinsfunctions will fail if
108c5604d0aSTim J. Robbins.Fa n
109c5604d0aSTim J. Robbinsor more wide characters were requested to be written,
110c5604d0aSTim J. Robbins.Pp
111c5604d0aSTim J. RobbinsThe format string is composed of zero or more directives:
112c5604d0aSTim J. Robbinsordinary
113c5604d0aSTim J. Robbinscharacters (not
114c5604d0aSTim J. Robbins.Cm % ) ,
115c5604d0aSTim J. Robbinswhich are copied unchanged to the output stream;
116c5604d0aSTim J. Robbinsand conversion specifications, each of which results
117c5604d0aSTim J. Robbinsin fetching zero or more subsequent arguments.
118c5604d0aSTim J. RobbinsEach conversion specification is introduced by
119c5604d0aSTim J. Robbinsthe
120c5604d0aSTim J. Robbins.Cm %
121c5604d0aSTim J. Robbinscharacter.
122c5604d0aSTim J. RobbinsThe arguments must correspond properly (after type promotion)
123c5604d0aSTim J. Robbinswith the conversion specifier.
124c5604d0aSTim J. RobbinsAfter the
125c5604d0aSTim J. Robbins.Cm % ,
126c5604d0aSTim J. Robbinsthe following appear in sequence:
127c5604d0aSTim J. Robbins.Bl -bullet
128c5604d0aSTim J. Robbins.It
129c5604d0aSTim J. RobbinsAn optional field, consisting of a decimal digit string followed by a
130c5604d0aSTim J. Robbins.Cm $ ,
131c5604d0aSTim J. Robbinsspecifying the next argument to access.
132c5604d0aSTim J. RobbinsIf this field is not provided, the argument following the last
133c5604d0aSTim J. Robbinsargument accessed will be used.
134c5604d0aSTim J. RobbinsArguments are numbered starting at
135c5604d0aSTim J. Robbins.Cm 1 .
136c5604d0aSTim J. RobbinsIf unaccessed arguments in the format string are interspersed with ones that
137c5604d0aSTim J. Robbinsare accessed the results will be indeterminate.
138c5604d0aSTim J. Robbins.It
139c5604d0aSTim J. RobbinsZero or more of the following flags:
140c5604d0aSTim J. Robbins.Bl -tag -width ".So \  Sc (space)"
141c5604d0aSTim J. Robbins.It Sq Cm #
142c5604d0aSTim J. RobbinsThe value should be converted to an
143c5604d0aSTim J. Robbins.Dq alternate form .
144c5604d0aSTim J. RobbinsFor
145c5604d0aSTim J. Robbins.Cm c , d , i , n , p , s ,
146c5604d0aSTim J. Robbinsand
147c5604d0aSTim J. Robbins.Cm u
148c5604d0aSTim J. Robbinsconversions, this option has no effect.
149c5604d0aSTim J. RobbinsFor
150c5604d0aSTim J. Robbins.Cm o
151c5604d0aSTim J. Robbinsconversions, the precision of the number is increased to force the first
152c5604d0aSTim J. Robbinscharacter of the output string to a zero (except if a zero value is printed
153c5604d0aSTim J. Robbinswith an explicit precision of zero).
154c5604d0aSTim J. RobbinsFor
155c5604d0aSTim J. Robbins.Cm x
156c5604d0aSTim J. Robbinsand
157c5604d0aSTim J. Robbins.Cm X
158c5604d0aSTim J. Robbinsconversions, a non-zero result has the string
159c5604d0aSTim J. Robbins.Ql 0x
160c5604d0aSTim J. Robbins(or
161c5604d0aSTim J. Robbins.Ql 0X
162c5604d0aSTim J. Robbinsfor
163c5604d0aSTim J. Robbins.Cm X
164c5604d0aSTim J. Robbinsconversions) prepended to it.
165c5604d0aSTim J. RobbinsFor
166c5604d0aSTim J. Robbins.Cm a , A , e , E , f , F , g ,
167c5604d0aSTim J. Robbinsand
168c5604d0aSTim J. Robbins.Cm G
169c5604d0aSTim J. Robbinsconversions, the result will always contain a decimal point, even if no
170c5604d0aSTim J. Robbinsdigits follow it (normally, a decimal point appears in the results of
171c5604d0aSTim J. Robbinsthose conversions only if a digit follows).
172c5604d0aSTim J. RobbinsFor
173c5604d0aSTim J. Robbins.Cm g
174c5604d0aSTim J. Robbinsand
175c5604d0aSTim J. Robbins.Cm G
176c5604d0aSTim J. Robbinsconversions, trailing zeros are not removed from the result as they
177c5604d0aSTim J. Robbinswould otherwise be.
178c5604d0aSTim J. Robbins.It So Cm 0 Sc (zero)
179c5604d0aSTim J. RobbinsZero padding.
180c5604d0aSTim J. RobbinsFor all conversions except
181c5604d0aSTim J. Robbins.Cm n ,
182c5604d0aSTim J. Robbinsthe converted value is padded on the left with zeros rather than blanks.
183c5604d0aSTim J. RobbinsIf a precision is given with a numeric conversion
184c5604d0aSTim J. Robbins.Cm ( d , i , o , u , i , x ,
185c5604d0aSTim J. Robbinsand
186c5604d0aSTim J. Robbins.Cm X ) ,
187c5604d0aSTim J. Robbinsthe
188c5604d0aSTim J. Robbins.Cm 0
189c5604d0aSTim J. Robbinsflag is ignored.
190c5604d0aSTim J. Robbins.It Sq Cm \-
191c5604d0aSTim J. RobbinsA negative field width flag;
192c5604d0aSTim J. Robbinsthe converted value is to be left adjusted on the field boundary.
193c5604d0aSTim J. RobbinsExcept for
194c5604d0aSTim J. Robbins.Cm n
195c5604d0aSTim J. Robbinsconversions, the converted value is padded on the right with blanks,
196c5604d0aSTim J. Robbinsrather than on the left with blanks or zeros.
197c5604d0aSTim J. RobbinsA
198c5604d0aSTim J. Robbins.Cm \-
199c5604d0aSTim J. Robbinsoverrides a
200c5604d0aSTim J. Robbins.Cm 0
201c5604d0aSTim J. Robbinsif both are given.
202c5604d0aSTim J. Robbins.It So "\ " Sc (space)
203c5604d0aSTim J. RobbinsA blank should be left before a positive number
204c5604d0aSTim J. Robbinsproduced by a signed conversion
205c5604d0aSTim J. Robbins.Cm ( a , A , d , e , E , f , F , g , G ,
206c5604d0aSTim J. Robbinsor
207c5604d0aSTim J. Robbins.Cm i ) .
208c5604d0aSTim J. Robbins.It Sq Cm +
209c5604d0aSTim J. RobbinsA sign must always be placed before a
210c5604d0aSTim J. Robbinsnumber produced by a signed conversion.
211c5604d0aSTim J. RobbinsA
212c5604d0aSTim J. Robbins.Cm +
213c5604d0aSTim J. Robbinsoverrides a space if both are used.
214c5604d0aSTim J. Robbins.It Sq Cm '
215c5604d0aSTim J. RobbinsDecimal conversions
216c5604d0aSTim J. Robbins.Cm ( d , u ,
217c5604d0aSTim J. Robbinsor
218c5604d0aSTim J. Robbins.Cm i )
219c5604d0aSTim J. Robbinsor the integral portion of a floating point conversion
220c5604d0aSTim J. Robbins.Cm ( f
221c5604d0aSTim J. Robbinsor
222c5604d0aSTim J. Robbins.Cm F )
223c5604d0aSTim J. Robbinsshould be grouped and separated by thousands using
224c5604d0aSTim J. Robbinsthe non-monetary separator returned by
225c5604d0aSTim J. Robbins.Xr localeconv 3 .
226c5604d0aSTim J. Robbins.El
227c5604d0aSTim J. Robbins.It
228c5604d0aSTim J. RobbinsAn optional decimal digit string specifying a minimum field width.
229c5604d0aSTim J. RobbinsIf the converted value has fewer characters than the field width, it will
230c5604d0aSTim J. Robbinsbe padded with spaces on the left (or right, if the left-adjustment
231c5604d0aSTim J. Robbinsflag has been given) to fill out
232c5604d0aSTim J. Robbinsthe field width.
233c5604d0aSTim J. Robbins.It
234c5604d0aSTim J. RobbinsAn optional precision, in the form of a period
235c5604d0aSTim J. Robbins.Cm \&.
236c5604d0aSTim J. Robbinsfollowed by an
237c5604d0aSTim J. Robbinsoptional digit string.
238c5604d0aSTim J. RobbinsIf the digit string is omitted, the precision is taken as zero.
239c5604d0aSTim J. RobbinsThis gives the minimum number of digits to appear for
240c5604d0aSTim J. Robbins.Cm d , i , o , u , x ,
241c5604d0aSTim J. Robbinsand
242c5604d0aSTim J. Robbins.Cm X
243c5604d0aSTim J. Robbinsconversions, the number of digits to appear after the decimal-point for
244c5604d0aSTim J. Robbins.Cm a , A , e , E , f ,
245c5604d0aSTim J. Robbinsand
246c5604d0aSTim J. Robbins.Cm F
247c5604d0aSTim J. Robbinsconversions, the maximum number of significant digits for
248c5604d0aSTim J. Robbins.Cm g
249c5604d0aSTim J. Robbinsand
250c5604d0aSTim J. Robbins.Cm G
251c5604d0aSTim J. Robbinsconversions, or the maximum number of characters to be printed from a
252c5604d0aSTim J. Robbinsstring for
253c5604d0aSTim J. Robbins.Cm s
254c5604d0aSTim J. Robbinsconversions.
255c5604d0aSTim J. Robbins.It
256c5604d0aSTim J. RobbinsAn optional length modifier, that specifies the size of the argument.
257c5604d0aSTim J. RobbinsThe following length modifiers are valid for the
258c5604d0aSTim J. Robbins.Cm d , i , n , o , u , x ,
259c5604d0aSTim J. Robbinsor
260c5604d0aSTim J. Robbins.Cm X
261c5604d0aSTim J. Robbinsconversion:
262c5604d0aSTim J. Robbins.Bl -column ".Cm q Em (deprecated)" ".Vt signed char" ".Vt unsigned long long" ".Vt long long *"
263c5604d0aSTim J. Robbins.It Sy Modifier Ta Cm d , i Ta Cm o , u , x , X Ta Cm n
264c5604d0aSTim J. Robbins.It Cm hh Ta Vt "signed char" Ta Vt "unsigned char" Ta Vt "signed char *"
265c5604d0aSTim J. Robbins.It Cm h Ta Vt short Ta Vt "unsigned short" Ta Vt "short *"
266c5604d0aSTim J. Robbins.It Cm l No (ell) Ta Vt long Ta Vt "unsigned long" Ta Vt "long *"
267c5604d0aSTim J. Robbins.It Cm ll No (ell ell) Ta Vt "long long" Ta Vt "unsigned long long" Ta Vt "long long *"
268c5604d0aSTim J. Robbins.It Cm j Ta Vt intmax_t Ta Vt uintmax_t Ta Vt "intmax_t *"
269c5604d0aSTim J. Robbins.It Cm t Ta Vt ptrdiff_t Ta (see note) Ta Vt "ptrdiff_t *"
270c5604d0aSTim J. Robbins.It Cm z Ta (see note) Ta Vt size_t Ta (see note)
271c5604d0aSTim J. Robbins.It Cm q Em (deprecated) Ta Vt quad_t Ta Vt u_quad_t Ta Vt "quad_t *"
272c5604d0aSTim J. Robbins.El
273c5604d0aSTim J. Robbins.Pp
274c5604d0aSTim J. RobbinsNote:
275c5604d0aSTim J. Robbinsthe
276c5604d0aSTim J. Robbins.Cm t
277c5604d0aSTim J. Robbinsmodifier, when applied to a
278c5604d0aSTim J. Robbins.Cm o , u , x ,
279c5604d0aSTim J. Robbinsor
280c5604d0aSTim J. Robbins.Cm X
281c5604d0aSTim J. Robbinsconversion, indicates that the argument is of an unsigned type
282c5604d0aSTim J. Robbinsequivalent in size to a
283c5604d0aSTim J. Robbins.Vt ptrdiff_t .
284c5604d0aSTim J. RobbinsThe
285c5604d0aSTim J. Robbins.Cm z
286c5604d0aSTim J. Robbinsmodifier, when applied to a
287c5604d0aSTim J. Robbins.Cm d
288c5604d0aSTim J. Robbinsor
289c5604d0aSTim J. Robbins.Cm i
290c5604d0aSTim J. Robbinsconversion, indicates that the argument is of a signed type equivalent in
291c5604d0aSTim J. Robbinssize to a
292c5604d0aSTim J. Robbins.Vt size_t .
293c5604d0aSTim J. RobbinsSimilarly, when applied to an
294c5604d0aSTim J. Robbins.Cm n
295c5604d0aSTim J. Robbinsconversion, it indicates that the argument is a pointer to a signed type
296c5604d0aSTim J. Robbinsequivalent in size to a
297c5604d0aSTim J. Robbins.Vt size_t .
298c5604d0aSTim J. Robbins.Pp
299c5604d0aSTim J. RobbinsThe following length modifier is valid for the
300c5604d0aSTim J. Robbins.Cm a , A , e , E , f , F , g ,
301c5604d0aSTim J. Robbinsor
302c5604d0aSTim J. Robbins.Cm G
303c5604d0aSTim J. Robbinsconversion:
304c5604d0aSTim J. Robbins.Bl -column ".Sy Modifier" ".Cm a , A , e , E , f , F , g , G"
305c5604d0aSTim J. Robbins.It Sy Modifier Ta Cm a , A , e , E , f , F , g , G
306c5604d0aSTim J. Robbins.It Cm L Ta Vt "long double"
307c5604d0aSTim J. Robbins.El
308c5604d0aSTim J. Robbins.Pp
309c5604d0aSTim J. RobbinsThe following length modifier is valid for the
310c5604d0aSTim J. Robbins.Cm c
311c5604d0aSTim J. Robbinsor
312c5604d0aSTim J. Robbins.Cm s
313c5604d0aSTim J. Robbinsconversion:
314c5604d0aSTim J. Robbins.Bl -column ".Sy Modifier" ".Vt wint_t" ".Vt wchar_t *"
315c5604d0aSTim J. Robbins.It Sy Modifier Ta Cm c Ta Cm s
316c5604d0aSTim J. Robbins.It Cm l No (ell) Ta Vt wint_t Ta Vt "wchar_t *"
317c5604d0aSTim J. Robbins.El
318c5604d0aSTim J. Robbins.It
319c5604d0aSTim J. RobbinsA character that specifies the type of conversion to be applied.
320c5604d0aSTim J. Robbins.El
321c5604d0aSTim J. Robbins.Pp
322c5604d0aSTim J. RobbinsA field width or precision, or both, may be indicated by
323c5604d0aSTim J. Robbinsan asterisk
324c5604d0aSTim J. Robbins.Ql *
325c5604d0aSTim J. Robbinsor an asterisk followed by one or more decimal digits and a
326c5604d0aSTim J. Robbins.Ql $
327c5604d0aSTim J. Robbinsinstead of a
328c5604d0aSTim J. Robbinsdigit string.
329c5604d0aSTim J. RobbinsIn this case, an
330c5604d0aSTim J. Robbins.Vt int
331c5604d0aSTim J. Robbinsargument supplies the field width or precision.
332c5604d0aSTim J. RobbinsA negative field width is treated as a left adjustment flag followed by a
333c5604d0aSTim J. Robbinspositive field width; a negative precision is treated as though it were
334c5604d0aSTim J. Robbinsmissing.
335c5604d0aSTim J. RobbinsIf a single format directive mixes positional
336c5604d0aSTim J. Robbins.Pq Li nn$
337c5604d0aSTim J. Robbinsand non-positional arguments, the results are undefined.
338c5604d0aSTim J. Robbins.Pp
339c5604d0aSTim J. RobbinsThe conversion specifiers and their meanings are:
340c5604d0aSTim J. Robbins.Bl -tag -width ".Cm diouxX"
341c5604d0aSTim J. Robbins.It Cm diouxX
342c5604d0aSTim J. RobbinsThe
343c5604d0aSTim J. Robbins.Vt int
344c5604d0aSTim J. Robbins(or appropriate variant) argument is converted to signed decimal
345c5604d0aSTim J. Robbins.Cm ( d
346c5604d0aSTim J. Robbinsand
347c5604d0aSTim J. Robbins.Cm i ) ,
348c5604d0aSTim J. Robbinsunsigned octal
349c5604d0aSTim J. Robbins.Pq Cm o ,
350c5604d0aSTim J. Robbinsunsigned decimal
351c5604d0aSTim J. Robbins.Pq Cm u ,
352c5604d0aSTim J. Robbinsor unsigned hexadecimal
353c5604d0aSTim J. Robbins.Cm ( x
354c5604d0aSTim J. Robbinsand
355c5604d0aSTim J. Robbins.Cm X )
356c5604d0aSTim J. Robbinsnotation.
357c5604d0aSTim J. RobbinsThe letters
358c5604d0aSTim J. Robbins.Dq Li abcdef
359c5604d0aSTim J. Robbinsare used for
360c5604d0aSTim J. Robbins.Cm x
361c5604d0aSTim J. Robbinsconversions; the letters
362c5604d0aSTim J. Robbins.Dq Li ABCDEF
363c5604d0aSTim J. Robbinsare used for
364c5604d0aSTim J. Robbins.Cm X
365c5604d0aSTim J. Robbinsconversions.
366c5604d0aSTim J. RobbinsThe precision, if any, gives the minimum number of digits that must
367c5604d0aSTim J. Robbinsappear; if the converted value requires fewer digits, it is padded on
368c5604d0aSTim J. Robbinsthe left with zeros.
369c5604d0aSTim J. Robbins.It Cm DOU
370c5604d0aSTim J. RobbinsThe
371c5604d0aSTim J. Robbins.Vt "long int"
372c5604d0aSTim J. Robbinsargument is converted to signed decimal, unsigned octal, or unsigned
373c5604d0aSTim J. Robbinsdecimal, as if the format had been
374c5604d0aSTim J. Robbins.Cm ld , lo ,
375c5604d0aSTim J. Robbinsor
376c5604d0aSTim J. Robbins.Cm lu
377c5604d0aSTim J. Robbinsrespectively.
378c5604d0aSTim J. RobbinsThese conversion characters are deprecated, and will eventually disappear.
379c5604d0aSTim J. Robbins.It Cm eE
380c5604d0aSTim J. RobbinsThe
381c5604d0aSTim J. Robbins.Vt double
382c5604d0aSTim J. Robbinsargument is rounded and converted in the style
383c5604d0aSTim J. Robbins.Sm off
384c5604d0aSTim J. Robbins.Oo \- Oc Ar d Li \&. Ar ddd Li e \\*[Pm] Ar dd
385c5604d0aSTim J. Robbins.Sm on
386c5604d0aSTim J. Robbinswhere there is one digit before the
387c5604d0aSTim J. Robbinsdecimal-point character
388c5604d0aSTim J. Robbinsand the number of digits after it is equal to the precision;
389c5604d0aSTim J. Robbinsif the precision is missing,
390c5604d0aSTim J. Robbinsit is taken as 6; if the precision is
391c5604d0aSTim J. Robbinszero, no decimal-point character appears.
392c5604d0aSTim J. RobbinsAn
393c5604d0aSTim J. Robbins.Cm E
394c5604d0aSTim J. Robbinsconversion uses the letter
395c5604d0aSTim J. Robbins.Ql E
396c5604d0aSTim J. Robbins(rather than
397c5604d0aSTim J. Robbins.Ql e )
398c5604d0aSTim J. Robbinsto introduce the exponent.
399c5604d0aSTim J. RobbinsThe exponent always contains at least two digits; if the value is zero,
400c5604d0aSTim J. Robbinsthe exponent is 00.
401c5604d0aSTim J. Robbins.Pp
402c5604d0aSTim J. RobbinsFor
403c5604d0aSTim J. Robbins.Cm a , A , e , E , f , F , g ,
404c5604d0aSTim J. Robbinsand
405c5604d0aSTim J. Robbins.Cm G
406c5604d0aSTim J. Robbinsconversions, positive and negative infinity are represented as
407c5604d0aSTim J. Robbins.Li inf
408c5604d0aSTim J. Robbinsand
409c5604d0aSTim J. Robbins.Li -inf
410c5604d0aSTim J. Robbinsrespectively when using the lowercase conversion character, and
411c5604d0aSTim J. Robbins.Li INF
412c5604d0aSTim J. Robbinsand
413c5604d0aSTim J. Robbins.Li -INF
414c5604d0aSTim J. Robbinsrespectively when using the uppercase conversion character.
415c5604d0aSTim J. RobbinsSimilarly, NaN is represented as
416c5604d0aSTim J. Robbins.Li nan
417c5604d0aSTim J. Robbinswhen using the lowercase conversion, and
418c5604d0aSTim J. Robbins.Li NAN
419c5604d0aSTim J. Robbinswhen using the uppercase conversion.
420c5604d0aSTim J. Robbins.It Cm fF
421c5604d0aSTim J. RobbinsThe
422c5604d0aSTim J. Robbins.Vt double
423c5604d0aSTim J. Robbinsargument is rounded and converted to decimal notation in the style
424c5604d0aSTim J. Robbins.Sm off
425c5604d0aSTim J. Robbins.Oo \- Oc Ar ddd Li \&. Ar ddd ,
426c5604d0aSTim J. Robbins.Sm on
427c5604d0aSTim J. Robbinswhere the number of digits after the decimal-point character
428c5604d0aSTim J. Robbinsis equal to the precision specification.
429c5604d0aSTim J. RobbinsIf the precision is missing, it is taken as 6; if the precision is
430c5604d0aSTim J. Robbinsexplicitly zero, no decimal-point character appears.
431c5604d0aSTim J. RobbinsIf a decimal point appears, at least one digit appears before it.
432c5604d0aSTim J. Robbins.It Cm gG
433c5604d0aSTim J. RobbinsThe
434c5604d0aSTim J. Robbins.Vt double
435c5604d0aSTim J. Robbinsargument is converted in style
436c5604d0aSTim J. Robbins.Cm f
437c5604d0aSTim J. Robbinsor
438c5604d0aSTim J. Robbins.Cm e
439c5604d0aSTim J. Robbins(or
440c5604d0aSTim J. Robbins.Cm F
441c5604d0aSTim J. Robbinsor
442c5604d0aSTim J. Robbins.Cm E
443c5604d0aSTim J. Robbinsfor
444c5604d0aSTim J. Robbins.Cm G
445c5604d0aSTim J. Robbinsconversions).
446c5604d0aSTim J. RobbinsThe precision specifies the number of significant digits.
447c5604d0aSTim J. RobbinsIf the precision is missing, 6 digits are given; if the precision is zero,
448c5604d0aSTim J. Robbinsit is treated as 1.
449c5604d0aSTim J. RobbinsStyle
450c5604d0aSTim J. Robbins.Cm e
451c5604d0aSTim J. Robbinsis used if the exponent from its conversion is less than \-4 or greater than
452c5604d0aSTim J. Robbinsor equal to the precision.
453c5604d0aSTim J. RobbinsTrailing zeros are removed from the fractional part of the result; a
454c5604d0aSTim J. Robbinsdecimal point appears only if it is followed by at least one digit.
455c5604d0aSTim J. Robbins.It Cm aA
456c5604d0aSTim J. RobbinsThe
457c5604d0aSTim J. Robbins.Vt double
458c5604d0aSTim J. Robbinsargument is converted to hexadecimal notation in the style
459c5604d0aSTim J. Robbins.Sm off
460c5604d0aSTim J. Robbins.Oo \- Oc Li 0x Ar h Li \&. Ar hhhp Oo \\*[Pm] Oc Ar d ,
461c5604d0aSTim J. Robbins.Sm on
462c5604d0aSTim J. Robbinswhere the number of digits after the hexadecimal-point character
463c5604d0aSTim J. Robbinsis equal to the precision specification.
464c5604d0aSTim J. RobbinsIf the precision is missing, it is taken as enough to exactly
465c5604d0aSTim J. Robbinsrepresent the floating-point number; if the precision is
466c5604d0aSTim J. Robbinsexplicitly zero, no hexadecimal-point character appears.
467c5604d0aSTim J. RobbinsThis is an exact conversion of the mantissa+exponent internal
468c5604d0aSTim J. Robbinsfloating point representation; the
469c5604d0aSTim J. Robbins.Sm off
470c5604d0aSTim J. Robbins.Oo \- Oc Li 0x Ar h Li \&. Ar hhh
471c5604d0aSTim J. Robbins.Sm on
472c5604d0aSTim J. Robbinsportion represents exactly the mantissa; only denormalized
473c5604d0aSTim J. Robbinsmantissas have a zero value to the left of the hexadecimal
474c5604d0aSTim J. Robbinspoint.
475c5604d0aSTim J. RobbinsThe
476c5604d0aSTim J. Robbins.Cm p
477c5604d0aSTim J. Robbinsis a literal character
478c5604d0aSTim J. Robbins.Ql p ;
479c5604d0aSTim J. Robbinsthe exponent is preceded by a positive or negative sign
480c5604d0aSTim J. Robbinsand is represented in decimal, using only enough characters
481c5604d0aSTim J. Robbinsto represent the exponent.
482c5604d0aSTim J. RobbinsThe
483c5604d0aSTim J. Robbins.Cm A
484c5604d0aSTim J. Robbinsconversion uses the prefix
485c5604d0aSTim J. Robbins.Dq Li 0X
486c5604d0aSTim J. Robbins(rather than
487c5604d0aSTim J. Robbins.Dq Li 0x ) ,
488c5604d0aSTim J. Robbinsthe letters
489c5604d0aSTim J. Robbins.Dq Li ABCDEF
490c5604d0aSTim J. Robbins(rather than
491c5604d0aSTim J. Robbins.Dq Li abcdef )
492c5604d0aSTim J. Robbinsto represent the hex digits, and the letter
493c5604d0aSTim J. Robbins.Ql P
494c5604d0aSTim J. Robbins(rather than
495c5604d0aSTim J. Robbins.Ql p )
496c5604d0aSTim J. Robbinsto separate the mantissa and exponent.
497c5604d0aSTim J. Robbins.It Cm C
498c5604d0aSTim J. RobbinsTreated as
499c5604d0aSTim J. Robbins.Cm c
500c5604d0aSTim J. Robbinswith the
501c5604d0aSTim J. Robbins.Cm l
502c5604d0aSTim J. Robbins(ell) modifier.
503c5604d0aSTim J. Robbins.It Cm c
504c5604d0aSTim J. RobbinsThe
505c5604d0aSTim J. Robbins.Vt int
506c5604d0aSTim J. Robbinsargument is converted to an
507c5604d0aSTim J. Robbins.Vt "unsigned char" ,
508c5604d0aSTim J. Robbinsthen to a
509c5604d0aSTim J. Robbins.Vt wchar_t
510c5604d0aSTim J. Robbinsas if by
511c5604d0aSTim J. Robbins.Xr btowc 3 ,
512c5604d0aSTim J. Robbinsand the resulting character is written.
513c5604d0aSTim J. Robbins.Pp
514c5604d0aSTim J. RobbinsIf the
515c5604d0aSTim J. Robbins.Cm l
516c5604d0aSTim J. Robbins(ell) modifier is used, the
517c5604d0aSTim J. Robbins.Vt wint_t
518c5604d0aSTim J. Robbinsargument is converted to a
519c5604d0aSTim J. Robbins.Vt wchar_t
520c5604d0aSTim J. Robbinsand written.
521c5604d0aSTim J. Robbins.It Cm S
522c5604d0aSTim J. RobbinsTreated as
523c5604d0aSTim J. Robbins.Cm s
524c5604d0aSTim J. Robbinswith the
525c5604d0aSTim J. Robbins.Cm l
526c5604d0aSTim J. Robbins(ell) modifier.
527c5604d0aSTim J. Robbins.It Cm s
528c5604d0aSTim J. RobbinsThe
529c5604d0aSTim J. Robbins.Vt "char *"
530c5604d0aSTim J. Robbinsargument is expected to be a pointer to an array of character type (pointer
531c5604d0aSTim J. Robbinsto a string) containing a multibyte sequence.
532c5604d0aSTim J. RobbinsCharacters from the array are converted to wide characters and written up to
533c5604d0aSTim J. Robbins(but not including)
534c5604d0aSTim J. Robbinsa terminating
535c5604d0aSTim J. Robbins.Dv NUL
536c5604d0aSTim J. Robbinscharacter;
537c5604d0aSTim J. Robbinsif a precision is specified, no more than the number specified are
538c5604d0aSTim J. Robbinswritten.
539c5604d0aSTim J. RobbinsIf a precision is given, no null character
540c5604d0aSTim J. Robbinsneed be present; if the precision is not specified, or is greater than
541c5604d0aSTim J. Robbinsthe size of the array, the array must contain a terminating
542c5604d0aSTim J. Robbins.Dv NUL
543c5604d0aSTim J. Robbinscharacter.
544c5604d0aSTim J. Robbins.Pp
545c5604d0aSTim J. RobbinsIf the
546c5604d0aSTim J. Robbins.Cm l
547c5604d0aSTim J. Robbins(ell) modifier is used, the
548c5604d0aSTim J. Robbins.Vt "wchar_t *"
549c5604d0aSTim J. Robbinsargument is expected to be a pointer to an array of wide characters
550c5604d0aSTim J. Robbins(pointer to a wide string).
551c5604d0aSTim J. RobbinsEach wide character in the string
552c5604d0aSTim J. Robbinsis written.
553c5604d0aSTim J. RobbinsWide characters from the array are written up to (but not including)
554c5604d0aSTim J. Robbinsa terminating wide
555c5604d0aSTim J. Robbins.Dv NUL
556c5604d0aSTim J. Robbinscharacter;
557c5604d0aSTim J. Robbinsif a precision is specified, no more than the number specified are
558c5604d0aSTim J. Robbinswritten (including shift sequences).
559c5604d0aSTim J. RobbinsIf a precision is given, no null character
560c5604d0aSTim J. Robbinsneed be present; if the precision is not specified, or is greater than
561c5604d0aSTim J. Robbinsthe number of characters in
562c5604d0aSTim J. Robbinsthe string, the array must contain a terminating wide
563c5604d0aSTim J. Robbins.Dv NUL
564c5604d0aSTim J. Robbinscharacter.
565c5604d0aSTim J. Robbins.It Cm p
566c5604d0aSTim J. RobbinsThe
567c5604d0aSTim J. Robbins.Vt "void *"
568c5604d0aSTim J. Robbinspointer argument is printed in hexadecimal (as if by
569c5604d0aSTim J. Robbins.Ql %#x
570c5604d0aSTim J. Robbinsor
571c5604d0aSTim J. Robbins.Ql %#lx ) .
572c5604d0aSTim J. Robbins.It Cm n
573c5604d0aSTim J. RobbinsThe number of characters written so far is stored into the
574c5604d0aSTim J. Robbinsinteger indicated by the
575c5604d0aSTim J. Robbins.Vt "int *"
576c5604d0aSTim J. Robbins(or variant) pointer argument.
577c5604d0aSTim J. RobbinsNo argument is converted.
578c5604d0aSTim J. Robbins.It Cm %
579c5604d0aSTim J. RobbinsA
580c5604d0aSTim J. Robbins.Ql %
581c5604d0aSTim J. Robbinsis written.
582c5604d0aSTim J. RobbinsNo argument is converted.
583c5604d0aSTim J. RobbinsThe complete conversion specification
584c5604d0aSTim J. Robbinsis
585c5604d0aSTim J. Robbins.Ql %% .
586c5604d0aSTim J. Robbins.El
587c5604d0aSTim J. Robbins.Pp
588c5604d0aSTim J. RobbinsThe decimal point
589c5604d0aSTim J. Robbinscharacter is defined in the program's locale (category
590c5604d0aSTim J. Robbins.Dv LC_NUMERIC ) .
591c5604d0aSTim J. Robbins.Pp
592c5604d0aSTim J. RobbinsIn no case does a non-existent or small field width cause truncation of
593c5604d0aSTim J. Robbinsa numeric field; if the result of a conversion is wider than the field
594c5604d0aSTim J. Robbinswidth, the
595c5604d0aSTim J. Robbinsfield is expanded to contain the conversion result.
596c5604d0aSTim J. Robbins.Sh SECURITY CONSIDERATIONS
597c5604d0aSTim J. RobbinsRefer to
598c5604d0aSTim J. Robbins.Xr printf 3 .
599c5604d0aSTim J. Robbins.Sh SEE ALSO
600c5604d0aSTim J. Robbins.Xr printf 3 ,
601c5604d0aSTim J. Robbins.Xr setlocale 3
602c5604d0aSTim J. Robbins.Sh STANDARDS
603c5604d0aSTim J. RobbinsSubject to the caveats noted in the
604c5604d0aSTim J. Robbins.Sx BUGS
605c5604d0aSTim J. Robbinssection
606c5604d0aSTim J. Robbinsof
607c5604d0aSTim J. Robbins.Xr printf 3 ,
608c5604d0aSTim J. Robbinsthe
609c5604d0aSTim J. Robbins.Fn wprintf ,
610c5604d0aSTim J. Robbins.Fn fwprintf ,
611c5604d0aSTim J. Robbins.Fn swprintf ,
612c5604d0aSTim J. Robbins.Fn vwprintf ,
613c5604d0aSTim J. Robbins.Fn vfwprintf
614c5604d0aSTim J. Robbinsand
615c5604d0aSTim J. Robbins.Fn vswprintf
616c5604d0aSTim J. Robbinsfunctions
617c5604d0aSTim J. Robbinsconform to
618c5604d0aSTim J. Robbins.St -isoC-99 .
619