xref: /freebsd/lib/libc/stdio/printf.3 (revision 2357939bc239bd5334a169b62313806178dd8f30)
1.\" Copyright (c) 1990, 1991, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" Chris Torek and the American National Standards Committee X3,
6.\" on Information Processing Systems.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\"    notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\"    notice, this list of conditions and the following disclaimer in the
15.\"    documentation and/or other materials provided with the distribution.
16.\" 3. All advertising materials mentioning features or use of this software
17.\"    must display the following acknowledgement:
18.\"	This product includes software developed by the University of
19.\"	California, Berkeley and its contributors.
20.\" 4. Neither the name of the University nor the names of its contributors
21.\"    may be used to endorse or promote products derived from this software
22.\"    without specific prior written permission.
23.\"
24.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34.\" SUCH DAMAGE.
35.\"
36.\"     @(#)printf.3	8.1 (Berkeley) 6/4/93
37.\" $FreeBSD$
38.\"
39.Dd January 18, 2004
40.Dt PRINTF 3
41.Os
42.Sh NAME
43.Nm printf , fprintf , sprintf , snprintf , asprintf ,
44.Nm vprintf , vfprintf, vsprintf , vsnprintf , vasprintf
45.Nd formatted output conversion
46.Sh LIBRARY
47.Lb libc
48.Sh SYNOPSIS
49.In stdio.h
50.Ft int
51.Fn printf "const char * restrict format" ...
52.Ft int
53.Fn fprintf "FILE * restrict stream" "const char * restrict format" ...
54.Ft int
55.Fn sprintf "char * restrict str" "const char * restrict format" ...
56.Ft int
57.Fn snprintf "char * restrict str" "size_t size" "const char * restrict format" ...
58.Ft int
59.Fn asprintf "char **ret" "const char *format" ...
60.In stdarg.h
61.Ft int
62.Fn vprintf "const char * restrict format" "va_list ap"
63.Ft int
64.Fn vfprintf "FILE * restrict stream" "const char * restrict format" "va_list ap"
65.Ft int
66.Fn vsprintf "char * restrict str" "const char * restrict format" "va_list ap"
67.Ft int
68.Fn vsnprintf "char * restrict str" "size_t size" "const char * restrict format" "va_list ap"
69.Ft int
70.Fn vasprintf "char **ret" "const char *format" "va_list ap"
71.Sh DESCRIPTION
72The
73.Fn printf
74family of functions produces output according to a
75.Fa format
76as described below.
77The
78.Fn printf
79and
80.Fn vprintf
81functions
82write output to
83.Dv stdout ,
84the standard output stream;
85.Fn fprintf
86and
87.Fn vfprintf
88write output to the given output
89.Fa stream ;
90.Fn sprintf ,
91.Fn snprintf ,
92.Fn vsprintf ,
93and
94.Fn vsnprintf
95write to the character string
96.Fa str ;
97and
98.Fn asprintf
99and
100.Fn vasprintf
101dynamically allocate a new string with
102.Xr malloc 3 .
103.Pp
104These functions write the output under the control of a
105.Fa format
106string that specifies how subsequent arguments
107(or arguments accessed via the variable-length argument facilities of
108.Xr stdarg 3 )
109are converted for output.
110.Pp
111These functions return the number of characters printed
112(not including the trailing
113.Ql \e0
114used to end output to strings) or a negative value if an output error occurs,
115except for
116.Fn snprintf
117and
118.Fn vsnprintf ,
119which return the number of characters that would have been printed if the
120.Fa size
121were unlimited
122(again, not including the final
123.Ql \e0 ) .
124.Pp
125The
126.Fn asprintf
127and
128.Fn vasprintf
129functions
130set
131.Fa *ret
132to be a pointer to a buffer sufficiently large to hold the formatted string.
133This pointer should be passed to
134.Xr free 3
135to release the allocated storage when it is no longer needed.
136If sufficient space cannot be allocated,
137.Fn asprintf
138and
139.Fn vasprintf
140will return \-1 and set
141.Fa ret
142to be a
143.Dv NULL
144pointer.
145.Pp
146The
147.Fn snprintf
148and
149.Fn vsnprintf
150functions
151will write at most
152.Fa size Ns \-1
153of the characters printed into the output string
154(the
155.Fa size Ns 'th
156character then gets the terminating
157.Ql \e0 ) ;
158if the return value is greater than or equal to the
159.Fa size
160argument, the string was too short
161and some of the printed characters were discarded.
162The output is always null-terminated.
163.Pp
164The
165.Fn sprintf
166and
167.Fn vsprintf
168functions
169effectively assume an infinite
170.Fa size .
171.Pp
172The format string is composed of zero or more directives:
173ordinary
174.\" multibyte
175characters (not
176.Cm % ) ,
177which are copied unchanged to the output stream;
178and conversion specifications, each of which results
179in fetching zero or more subsequent arguments.
180Each conversion specification is introduced by
181the
182.Cm %
183character.
184The arguments must correspond properly (after type promotion)
185with the conversion specifier.
186After the
187.Cm % ,
188the following appear in sequence:
189.Bl -bullet
190.It
191An optional field, consisting of a decimal digit string followed by a
192.Cm $ ,
193specifying the next argument to access.
194If this field is not provided, the argument following the last
195argument accessed will be used.
196Arguments are numbered starting at
197.Cm 1 .
198If unaccessed arguments in the format string are interspersed with ones that
199are accessed the results will be indeterminate.
200.It
201Zero or more of the following flags:
202.Bl -tag -width ".So \  Sc (space)"
203.It Sq Cm #
204The value should be converted to an
205.Dq alternate form .
206For
207.Cm c , d , i , n , p , s ,
208and
209.Cm u
210conversions, this option has no effect.
211For
212.Cm o
213conversions, the precision of the number is increased to force the first
214character of the output string to a zero (except if a zero value is printed
215with an explicit precision of zero).
216For
217.Cm x
218and
219.Cm X
220conversions, a non-zero result has the string
221.Ql 0x
222(or
223.Ql 0X
224for
225.Cm X
226conversions) prepended to it.
227For
228.Cm a , A , e , E , f , F , g ,
229and
230.Cm G
231conversions, the result will always contain a decimal point, even if no
232digits follow it (normally, a decimal point appears in the results of
233those conversions only if a digit follows).
234For
235.Cm g
236and
237.Cm G
238conversions, trailing zeros are not removed from the result as they
239would otherwise be.
240.It So Cm 0 Sc (zero)
241Zero padding.
242For all conversions except
243.Cm n ,
244the converted value is padded on the left with zeros rather than blanks.
245If a precision is given with a numeric conversion
246.Cm ( d , i , o , u , i , x ,
247and
248.Cm X ) ,
249the
250.Cm 0
251flag is ignored.
252.It Sq Cm \-
253A negative field width flag;
254the converted value is to be left adjusted on the field boundary.
255Except for
256.Cm n
257conversions, the converted value is padded on the right with blanks,
258rather than on the left with blanks or zeros.
259A
260.Cm \-
261overrides a
262.Cm 0
263if both are given.
264.It So "\ " Sc (space)
265A blank should be left before a positive number
266produced by a signed conversion
267.Cm ( a , A , d , e , E , f , F , g , G ,
268or
269.Cm i ) .
270.It Sq Cm +
271A sign must always be placed before a
272number produced by a signed conversion.
273A
274.Cm +
275overrides a space if both are used.
276.It Sq Cm '
277Decimal conversions
278.Cm ( d , u ,
279or
280.Cm i )
281or the integral portion of a floating point conversion
282.Cm ( f
283or
284.Cm F )
285should be grouped and separated by thousands using
286the non-monetary separator returned by
287.Xr localeconv 3 .
288.El
289.It
290An optional decimal digit string specifying a minimum field width.
291If the converted value has fewer characters than the field width, it will
292be padded with spaces on the left (or right, if the left-adjustment
293flag has been given) to fill out
294the field width.
295.It
296An optional precision, in the form of a period
297.Cm \&.
298followed by an
299optional digit string.
300If the digit string is omitted, the precision is taken as zero.
301This gives the minimum number of digits to appear for
302.Cm d , i , o , u , x ,
303and
304.Cm X
305conversions, the number of digits to appear after the decimal-point for
306.Cm a , A , e , E , f ,
307and
308.Cm F
309conversions, the maximum number of significant digits for
310.Cm g
311and
312.Cm G
313conversions, or the maximum number of characters to be printed from a
314string for
315.Cm s
316conversions.
317.It
318An optional length modifier, that specifies the size of the argument.
319The following length modifiers are valid for the
320.Cm d , i , n , o , u , x ,
321or
322.Cm X
323conversion:
324.Bl -column ".Cm q Em (deprecated)" ".Vt signed char" ".Vt unsigned long long" ".Vt long long *"
325.It Sy Modifier Ta Cm d , i Ta Cm o , u , x , X Ta Cm n
326.It Cm hh Ta Vt "signed char" Ta Vt "unsigned char" Ta Vt "signed char *"
327.It Cm h Ta Vt short Ta Vt "unsigned short" Ta Vt "short *"
328.It Cm l No (ell) Ta Vt long Ta Vt "unsigned long" Ta Vt "long *"
329.It Cm ll No (ell ell) Ta Vt "long long" Ta Vt "unsigned long long" Ta Vt "long long *"
330.It Cm j Ta Vt intmax_t Ta Vt uintmax_t Ta Vt "intmax_t *"
331.It Cm t Ta Vt ptrdiff_t Ta (see note) Ta Vt "ptrdiff_t *"
332.It Cm z Ta (see note) Ta Vt size_t Ta (see note)
333.It Cm q Em (deprecated) Ta Vt quad_t Ta Vt u_quad_t Ta Vt "quad_t *"
334.El
335.Pp
336Note:
337the
338.Cm t
339modifier, when applied to a
340.Cm o , u , x ,
341or
342.Cm X
343conversion, indicates that the argument is of an unsigned type
344equivalent in size to a
345.Vt ptrdiff_t .
346The
347.Cm z
348modifier, when applied to a
349.Cm d
350or
351.Cm i
352conversion, indicates that the argument is of a signed type equivalent in
353size to a
354.Vt size_t .
355Similarly, when applied to an
356.Cm n
357conversion, it indicates that the argument is a pointer to a signed type
358equivalent in size to a
359.Vt size_t .
360.Pp
361The following length modifier is valid for the
362.Cm a , A , e , E , f , F , g ,
363or
364.Cm G
365conversion:
366.Bl -column ".Sy Modifier" ".Cm a , A , e , E , f , F , g , G"
367.It Sy Modifier Ta Cm a , A , e , E , f , F , g , G
368.It Cm L Ta Vt "long double"
369.El
370.Pp
371The following length modifier is valid for the
372.Cm c
373or
374.Cm s
375conversion:
376.Bl -column ".Sy Modifier" ".Vt wint_t" ".Vt wchar_t *"
377.It Sy Modifier Ta Cm c Ta Cm s
378.It Cm l No (ell) Ta Vt wint_t Ta Vt "wchar_t *"
379.El
380.It
381A character that specifies the type of conversion to be applied.
382.El
383.Pp
384A field width or precision, or both, may be indicated by
385an asterisk
386.Ql *
387or an asterisk followed by one or more decimal digits and a
388.Ql $
389instead of a
390digit string.
391In this case, an
392.Vt int
393argument supplies the field width or precision.
394A negative field width is treated as a left adjustment flag followed by a
395positive field width; a negative precision is treated as though it were
396missing.
397If a single format directive mixes positional
398.Pq Li nn$
399and non-positional arguments, the results are undefined.
400.Pp
401The conversion specifiers and their meanings are:
402.Bl -tag -width ".Cm diouxX"
403.It Cm diouxX
404The
405.Vt int
406(or appropriate variant) argument is converted to signed decimal
407.Cm ( d
408and
409.Cm i ) ,
410unsigned octal
411.Pq Cm o ,
412unsigned decimal
413.Pq Cm u ,
414or unsigned hexadecimal
415.Cm ( x
416and
417.Cm X )
418notation.
419The letters
420.Dq Li abcdef
421are used for
422.Cm x
423conversions; the letters
424.Dq Li ABCDEF
425are used for
426.Cm X
427conversions.
428The precision, if any, gives the minimum number of digits that must
429appear; if the converted value requires fewer digits, it is padded on
430the left with zeros.
431.It Cm DOU
432The
433.Vt "long int"
434argument is converted to signed decimal, unsigned octal, or unsigned
435decimal, as if the format had been
436.Cm ld , lo ,
437or
438.Cm lu
439respectively.
440These conversion characters are deprecated, and will eventually disappear.
441.It Cm eE
442The
443.Vt double
444argument is rounded and converted in the style
445.Sm off
446.Oo \- Oc Ar d Li \&. Ar ddd Li e \\*[Pm] Ar dd
447.Sm on
448where there is one digit before the
449decimal-point character
450and the number of digits after it is equal to the precision;
451if the precision is missing,
452it is taken as 6; if the precision is
453zero, no decimal-point character appears.
454An
455.Cm E
456conversion uses the letter
457.Ql E
458(rather than
459.Ql e )
460to introduce the exponent.
461The exponent always contains at least two digits; if the value is zero,
462the exponent is 00.
463.Pp
464For
465.Cm a , A , e , E , f , F , g ,
466and
467.Cm G
468conversions, positive and negative infinity are represented as
469.Li inf
470and
471.Li -inf
472respectively when using the lowercase conversion character, and
473.Li INF
474and
475.Li -INF
476respectively when using the uppercase conversion character.
477Similarly, NaN is represented as
478.Li nan
479when using the lowercase conversion, and
480.Li NAN
481when using the uppercase conversion.
482.It Cm fF
483The
484.Vt double
485argument is rounded and converted to decimal notation in the style
486.Sm off
487.Oo \- Oc Ar ddd Li \&. Ar ddd ,
488.Sm on
489where the number of digits after the decimal-point character
490is equal to the precision specification.
491If the precision is missing, it is taken as 6; if the precision is
492explicitly zero, no decimal-point character appears.
493If a decimal point appears, at least one digit appears before it.
494.It Cm gG
495The
496.Vt double
497argument is converted in style
498.Cm f
499or
500.Cm e
501(or
502.Cm F
503or
504.Cm E
505for
506.Cm G
507conversions).
508The precision specifies the number of significant digits.
509If the precision is missing, 6 digits are given; if the precision is zero,
510it is treated as 1.
511Style
512.Cm e
513is used if the exponent from its conversion is less than \-4 or greater than
514or equal to the precision.
515Trailing zeros are removed from the fractional part of the result; a
516decimal point appears only if it is followed by at least one digit.
517.It Cm aA
518The
519.Vt double
520argument is rounded and converted to hexadecimal notation in the style
521.Sm off
522.Oo \- Oc Li 0x Ar h Li \&. Ar hhhp Oo \\*[Pm] Oc Ar d ,
523.Sm on
524where the number of digits after the hexadecimal-point character
525is equal to the precision specification.
526If the precision is missing, it is taken as enough to represent
527the floating-point number exactly, and no rounding occurs.
528If the precision is zero, no hexadecimal-point character appears.
529The
530.Cm p
531is a literal character
532.Ql p ,
533and the exponent consists of a positive or negative sign
534followed by a decimal number representing an exponent of 2.
535The
536.Cm A
537conversion uses the prefix
538.Dq Li 0X
539(rather than
540.Dq Li 0x ) ,
541the letters
542.Dq Li ABCDEF
543(rather than
544.Dq Li abcdef )
545to represent the hex digits, and the letter
546.Ql P
547(rather than
548.Ql p )
549to separate the mantissa and exponent.
550.Pp
551Note that there may be multiple valid ways to represent floating-point
552numbers in this hexadecimal format.  For example,
553.Li 0x3.24p+0
554and
555.Li 0x6.48p-1
556and
557.Li 0xc.9p-2
558are all equivalent.
559The format chosen depends on the internal representation of the
560number, but the implementation guarantees that the length of the
561mantissa will be minimized.
562Zeroes are always represented with a mantissa of 0 (preceded by a
563.Ql -
564if appropriate) and an exponent of
565.Li +0 .
566.It Cm C
567Treated as
568.Cm c
569with the
570.Cm l
571(ell) modifier.
572.It Cm c
573The
574.Vt int
575argument is converted to an
576.Vt "unsigned char" ,
577and the resulting character is written.
578.Pp
579If the
580.Cm l
581(ell) modifier is used, the
582.Vt wint_t
583argument shall be converted to a
584.Vt wchar_t ,
585and the (potentially multi-byte) sequence representing the
586single wide character is written, including any shift sequences.
587If a shift sequence is used, the shift state is also restored
588to the original state after the character.
589.It Cm S
590Treated as
591.Cm s
592with the
593.Cm l
594(ell) modifier.
595.It Cm s
596The
597.Vt "char *"
598argument is expected to be a pointer to an array of character type (pointer
599to a string).
600Characters from the array are written up to (but not including)
601a terminating
602.Dv NUL
603character;
604if a precision is specified, no more than the number specified are
605written.
606If a precision is given, no null character
607need be present; if the precision is not specified, or is greater than
608the size of the array, the array must contain a terminating
609.Dv NUL
610character.
611.Pp
612If the
613.Cm l
614(ell) modifier is used, the
615.Vt "wchar_t *"
616argument is expected to be a pointer to an array of wide characters
617(pointer to a wide string).
618For each wide character in the string, the (potentially multi-byte)
619sequence representing the
620wide character is written, including any shift sequences.
621If any shift sequence is used, the shift state is also restored
622to the original state after the string.
623Wide characters from the array are written up to (but not including)
624a terminating wide
625.Dv NUL
626character;
627if a precision is specified, no more than the number of bytes specified are
628written (including shift sequences).
629Partial characters are never written.
630If a precision is given, no null character
631need be present; if the precision is not specified, or is greater than
632the number of bytes required to render the multibyte representation of
633the string, the array must contain a terminating wide
634.Dv NUL
635character.
636.It Cm p
637The
638.Vt "void *"
639pointer argument is printed in hexadecimal (as if by
640.Ql %#x
641or
642.Ql %#lx ) .
643.It Cm n
644The number of characters written so far is stored into the
645integer indicated by the
646.Vt "int *"
647(or variant) pointer argument.
648No argument is converted.
649.It Cm %
650A
651.Ql %
652is written.
653No argument is converted.
654The complete conversion specification
655is
656.Ql %% .
657.El
658.Pp
659The decimal point
660character is defined in the program's locale (category
661.Dv LC_NUMERIC ) .
662.Pp
663In no case does a non-existent or small field width cause truncation of
664a numeric field; if the result of a conversion is wider than the field
665width, the
666field is expanded to contain the conversion result.
667.Sh EXAMPLES
668To print a date and time in the form
669.Dq Li "Sunday, July 3, 10:02" ,
670where
671.Fa weekday
672and
673.Fa month
674are pointers to strings:
675.Bd -literal -offset indent
676#include <stdio.h>
677fprintf(stdout, "%s, %s %d, %.2d:%.2d\en",
678	weekday, month, day, hour, min);
679.Ed
680.Pp
681To print \*(Pi
682to five decimal places:
683.Bd -literal -offset indent
684#include <math.h>
685#include <stdio.h>
686fprintf(stdout, "pi = %.5f\en", 4 * atan(1.0));
687.Ed
688.Pp
689To allocate a 128 byte string and print into it:
690.Bd -literal -offset indent
691#include <stdio.h>
692#include <stdlib.h>
693#include <stdarg.h>
694char *newfmt(const char *fmt, ...)
695{
696	char *p;
697	va_list ap;
698	if ((p = malloc(128)) == NULL)
699		return (NULL);
700	va_start(ap, fmt);
701	(void) vsnprintf(p, 128, fmt, ap);
702	va_end(ap);
703	return (p);
704}
705.Ed
706.Sh SECURITY CONSIDERATIONS
707The
708.Fn sprintf
709and
710.Fn vsprintf
711functions are easily misused in a manner which enables malicious users
712to arbitrarily change a running program's functionality through
713a buffer overflow attack.
714Because
715.Fn sprintf
716and
717.Fn vsprintf
718assume an infinitely long string,
719callers must be careful not to overflow the actual space;
720this is often hard to assure.
721For safety, programmers should use the
722.Fn snprintf
723interface instead.
724For example:
725.Bd -literal
726void
727foo(const char *arbitrary_string, const char *and_another)
728{
729	char onstack[8];
730
731#ifdef BAD
732	/*
733	 * This first sprintf is bad behavior.  Do not use sprintf!
734	 */
735	sprintf(onstack, "%s, %s", arbitrary_string, and_another);
736#else
737	/*
738	 * The following two lines demonstrate better use of
739	 * snprintf().
740	 */
741	snprintf(onstack, sizeof(onstack), "%s, %s", arbitrary_string,
742	    and_another);
743#endif
744}
745.Ed
746.Pp
747The
748.Fn printf
749and
750.Fn sprintf
751family of functions are also easily misused in a manner
752allowing malicious users to arbitrarily change a running program's
753functionality by either causing the program
754to print potentially sensitive data
755.Dq "left on the stack" ,
756or causing it to generate a memory fault or bus error
757by dereferencing an invalid pointer.
758.Pp
759.Cm %n
760can be used to write arbitrary data to potentially carefully-selected
761addresses.
762Programmers are therefore strongly advised to never pass untrusted strings
763as the
764.Fa format
765argument, as an attacker can put format specifiers in the string
766to mangle your stack,
767leading to a possible security hole.
768This holds true even if the string was built using a function like
769.Fn snprintf ,
770as the resulting string may still contain user-supplied conversion specifiers
771for later interpolation by
772.Fn printf .
773.Pp
774Always use the proper secure idiom:
775.Pp
776.Dl "snprintf(buffer, sizeof(buffer), \*q%s\*q, string);"
777.Sh ERRORS
778In addition to the errors documented for the
779.Xr write 2
780system call, the
781.Fn printf
782family of functions may fail if:
783.Bl -tag -width Er
784.It Bq Er EILSEQ
785An invalid wide character code was encountered.
786.It Bq Er ENOMEM
787Insufficient storage space is available.
788.El
789.Sh SEE ALSO
790.Xr printf 1 ,
791.Xr fmtcheck 3 ,
792.Xr scanf 3 ,
793.Xr setlocale 3 ,
794.Xr wprintf 3
795.Rs
796.%T "The FreeBSD Security Architecture"
797.Re
798(See
799.Pa "/usr/share/doc/{to be determined}" . )
800.Sh STANDARDS
801Subject to the caveats noted in the
802.Sx BUGS
803section below, the
804.Fn fprintf ,
805.Fn printf ,
806.Fn sprintf ,
807.Fn vprintf ,
808.Fn vfprintf ,
809and
810.Fn vsprintf
811functions
812conform to
813.St -ansiC
814and
815.St -isoC-99 .
816With the same reservation, the
817.Fn snprintf
818and
819.Fn vsnprintf
820functions conform to
821.St -isoC-99 .
822.Sh HISTORY
823The functions
824.Fn asprintf
825and
826.Fn vasprintf
827first appeared in the
828.Tn GNU C
829library.
830These were implemented by
831.An Peter Wemm Aq peter@FreeBSD.org
832in
833.Fx 2.2 ,
834but were later replaced with a different implementation
835from
836.An Todd C. Miller Aq Todd.Miller@courtesan.com
837for
838.Ox 2.3 .
839.Sh BUGS
840The conversion formats
841.Cm \&%D , \&%O ,
842and
843.Cm %U
844are not standard and
845are provided only for backward compatibility.
846The effect of padding the
847.Cm %p
848format with zeros (either by the
849.Cm 0
850flag or by specifying a precision), and the benign effect (i.e., none)
851of the
852.Cm #
853flag on
854.Cm %n
855and
856.Cm %p
857conversions, as well as other
858nonsensical combinations such as
859.Cm %Ld ,
860are not standard; such combinations
861should be avoided.
862.Pp
863The
864.Nm
865family of functions do not correctly handle multibyte characters in the
866.Fa format
867argument.
868