xref: /minix3/usr.bin/printf/printf.1 (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc.\"	$NetBSD: printf.1,v 1.25 2014/04/13 01:45:34 snj Exp $
22c96f054SLionel Sambuc.\"
32c96f054SLionel Sambuc.\" Copyright (c) 1989, 1990, 1993
42c96f054SLionel Sambuc.\"	The Regents of the University of California.  All rights reserved.
52c96f054SLionel Sambuc.\"
62c96f054SLionel Sambuc.\" This code is derived from software contributed to Berkeley by
72c96f054SLionel Sambuc.\" the Institute of Electrical and Electronics Engineers, Inc.
82c96f054SLionel Sambuc.\"
92c96f054SLionel Sambuc.\" Redistribution and use in source and binary forms, with or without
102c96f054SLionel Sambuc.\" modification, are permitted provided that the following conditions
112c96f054SLionel Sambuc.\" are met:
122c96f054SLionel Sambuc.\" 1. Redistributions of source code must retain the above copyright
132c96f054SLionel Sambuc.\"    notice, this list of conditions and the following disclaimer.
142c96f054SLionel Sambuc.\" 2. Redistributions in binary form must reproduce the above copyright
152c96f054SLionel Sambuc.\"    notice, this list of conditions and the following disclaimer in the
162c96f054SLionel Sambuc.\"    documentation and/or other materials provided with the distribution.
172c96f054SLionel Sambuc.\" 3. Neither the name of the University nor the names of its contributors
182c96f054SLionel Sambuc.\"    may be used to endorse or promote products derived from this software
192c96f054SLionel Sambuc.\"    without specific prior written permission.
202c96f054SLionel Sambuc.\"
212c96f054SLionel Sambuc.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
222c96f054SLionel Sambuc.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
232c96f054SLionel Sambuc.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
242c96f054SLionel Sambuc.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
252c96f054SLionel Sambuc.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
262c96f054SLionel Sambuc.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
272c96f054SLionel Sambuc.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
282c96f054SLionel Sambuc.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
292c96f054SLionel Sambuc.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
302c96f054SLionel Sambuc.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
312c96f054SLionel Sambuc.\" SUCH DAMAGE.
322c96f054SLionel Sambuc.\"
332c96f054SLionel Sambuc.\"	from: @(#)printf.1	8.1 (Berkeley) 6/6/93
342c96f054SLionel Sambuc.\"
352c96f054SLionel Sambuc.Dd May 6, 2008
362c96f054SLionel Sambuc.Dt PRINTF 1
372c96f054SLionel Sambuc.Os
382c96f054SLionel Sambuc.Sh NAME
392c96f054SLionel Sambuc.Nm printf
402c96f054SLionel Sambuc.Nd formatted output
412c96f054SLionel Sambuc.Sh SYNOPSIS
422c96f054SLionel Sambuc.Nm
432c96f054SLionel Sambuc.Ar format
442c96f054SLionel Sambuc.Op Ar arguments  ...
452c96f054SLionel Sambuc.Sh DESCRIPTION
462c96f054SLionel Sambuc.Nm
472c96f054SLionel Sambucformats and prints its arguments, after the first, under control
482c96f054SLionel Sambucof the
492c96f054SLionel Sambuc.Ar format  .
502c96f054SLionel SambucThe
512c96f054SLionel Sambuc.Ar format
522c96f054SLionel Sambucis a character string which contains three types of objects: plain characters,
532c96f054SLionel Sambucwhich are simply copied to standard output, character escape sequences which
542c96f054SLionel Sambucare converted and copied to the standard output, and format specifications,
552c96f054SLionel Sambuceach of which causes printing of the next successive
562c96f054SLionel Sambuc.Ar argument  .
572c96f054SLionel Sambuc.Pp
582c96f054SLionel SambucThe
592c96f054SLionel Sambuc.Ar arguments
602c96f054SLionel Sambucafter the first are treated as strings if the corresponding format is
612c96f054SLionel Sambuceither
622c96f054SLionel Sambuc.Cm b ,
632c96f054SLionel Sambuc.Cm B ,
642c96f054SLionel Sambuc.Cm c ,
652c96f054SLionel Sambucor
662c96f054SLionel Sambuc.Cm s ;
672c96f054SLionel Sambucotherwise it is evaluated as a C constant, with the following extensions:
682c96f054SLionel Sambuc.Pp
692c96f054SLionel Sambuc.Bl -bullet -offset indent -compact
702c96f054SLionel Sambuc.It
712c96f054SLionel SambucA leading plus or minus sign is allowed.
722c96f054SLionel Sambuc.It
732c96f054SLionel SambucIf the leading character is a single or double quote, the value is the
742c96f054SLionel Sambuc.Tn ASCII
752c96f054SLionel Sambuccode of the next character.
762c96f054SLionel Sambuc.El
772c96f054SLionel Sambuc.Pp
782c96f054SLionel SambucThe format string is reused as often as necessary to satisfy the
792c96f054SLionel Sambuc.Ar arguments  .
802c96f054SLionel SambucAny extra format specifications are evaluated with zero or the null
812c96f054SLionel Sambucstring.
822c96f054SLionel Sambuc.Pp
832c96f054SLionel SambucCharacter escape sequences are in backslash notation as defined in
842c96f054SLionel Sambuc.St -ansiC .
852c96f054SLionel SambucThe characters and their meanings are as follows:
862c96f054SLionel Sambuc.Bl -tag -width Ds -offset indent
872c96f054SLionel Sambuc.It Cm \ee
882c96f054SLionel SambucWrite an
892c96f054SLionel Sambuc.Aq escape
902c96f054SLionel Sambuccharacter.
912c96f054SLionel Sambuc.It Cm \ea
922c96f054SLionel SambucWrite a
932c96f054SLionel Sambuc.Aq bell
942c96f054SLionel Sambuccharacter.
952c96f054SLionel Sambuc.It Cm \eb
962c96f054SLionel SambucWrite a
972c96f054SLionel Sambuc.Aq backspace
982c96f054SLionel Sambuccharacter.
992c96f054SLionel Sambuc.It Cm \ef
1002c96f054SLionel SambucWrite a
1012c96f054SLionel Sambuc.Aq form-feed
1022c96f054SLionel Sambuccharacter.
1032c96f054SLionel Sambuc.It Cm \en
1042c96f054SLionel SambucWrite a
1052c96f054SLionel Sambuc.Aq new-line
1062c96f054SLionel Sambuccharacter.
1072c96f054SLionel Sambuc.It Cm \er
1082c96f054SLionel SambucWrite a
1092c96f054SLionel Sambuc.Aq carriage return
1102c96f054SLionel Sambuccharacter.
1112c96f054SLionel Sambuc.It Cm \et
1122c96f054SLionel SambucWrite a
1132c96f054SLionel Sambuc.Aq tab
1142c96f054SLionel Sambuccharacter.
1152c96f054SLionel Sambuc.It Cm \ev
1162c96f054SLionel SambucWrite a
1172c96f054SLionel Sambuc.Aq vertical tab
1182c96f054SLionel Sambuccharacter.
1192c96f054SLionel Sambuc.It Cm \e\'
1202c96f054SLionel SambucWrite a
1212c96f054SLionel Sambuc.Aq single quote
1222c96f054SLionel Sambuccharacter.
1232c96f054SLionel Sambuc.It Cm \e"
1242c96f054SLionel SambucWrite a
1252c96f054SLionel Sambuc.Aq double quote
1262c96f054SLionel Sambuccharacter.
1272c96f054SLionel Sambuc.It Cm \e\e
1282c96f054SLionel SambucWrite a backslash character.
1292c96f054SLionel Sambuc.It Cm \e Ns Ar num
1302c96f054SLionel SambucWrite an 8\-bit character whose
1312c96f054SLionel Sambuc.Tn ASCII
1322c96f054SLionel Sambucvalue is the 1\-, 2\-, or 3\-digit octal number
1332c96f054SLionel Sambuc.Ar num .
1342c96f054SLionel Sambuc.It Cm \ex Ns Ar xx
1352c96f054SLionel SambucWrite an 8\-bit character whose
1362c96f054SLionel Sambuc.Tn ASCII
1372c96f054SLionel Sambucvalue is the 1\- or 2\-digit hexadecimal number
1382c96f054SLionel Sambuc.Ar xx .
1392c96f054SLionel Sambuc.El
1402c96f054SLionel Sambuc.Pp
1412c96f054SLionel SambucEach format specification is introduced by the percent character
1422c96f054SLionel Sambuc.Pq Dq \&% .
1432c96f054SLionel SambucThe remainder of the format specification includes,
1442c96f054SLionel Sambucin the following order:
1452c96f054SLionel Sambuc.Bl -tag -width Ds
1462c96f054SLionel Sambuc.It Zero or more of the following flags :
1472c96f054SLionel Sambuc.Bl -tag -width Ds
1482c96f054SLionel Sambuc.It Cm #
1492c96f054SLionel SambucA
1502c96f054SLionel Sambuc.Sq #
1512c96f054SLionel Sambuccharacter specifying that the value should be printed in an
1522c96f054SLionel Sambuc.Dq alternative form .
1532c96f054SLionel SambucFor
1542c96f054SLionel Sambuc.Cm b ,
1552c96f054SLionel Sambuc.Cm c ,
1562c96f054SLionel Sambuc.Cm d ,
1572c96f054SLionel Sambucand
1582c96f054SLionel Sambuc.Cm s
1592c96f054SLionel Sambucformats, this option has no effect.
1602c96f054SLionel SambucFor the
1612c96f054SLionel Sambuc.Cm o
1622c96f054SLionel Sambucformat the precision of the number is increased to force the first
1632c96f054SLionel Sambuccharacter of the output string to a zero.
1642c96f054SLionel SambucFor the
1652c96f054SLionel Sambuc.Cm x
1662c96f054SLionel Sambuc.Pq Cm X
1672c96f054SLionel Sambucformat, a non-zero result has the string
1682c96f054SLionel Sambuc.Li 0x
1692c96f054SLionel Sambuc.Pq Li 0X
1702c96f054SLionel Sambucprepended to it.
1712c96f054SLionel SambucFor
1722c96f054SLionel Sambuc.Cm e ,
1732c96f054SLionel Sambuc.Cm E ,
1742c96f054SLionel Sambuc.Cm f ,
1752c96f054SLionel Sambuc.Cm g ,
1762c96f054SLionel Sambucand
1772c96f054SLionel Sambuc.Cm G
1782c96f054SLionel Sambucformats, the result will always contain a decimal point, even if no
1792c96f054SLionel Sambucdigits follow the point (normally, a decimal point only appears in the
1802c96f054SLionel Sambucresults of those formats if a digit follows the decimal point).
1812c96f054SLionel SambucFor
1822c96f054SLionel Sambuc.Cm g
1832c96f054SLionel Sambucand
1842c96f054SLionel Sambuc.Cm G
1852c96f054SLionel Sambucformats, trailing zeros are not removed from the result as they
1862c96f054SLionel Sambucwould otherwise be.
1872c96f054SLionel Sambuc.\" I turned this off - decided it isn't a valid use of '#'
1882c96f054SLionel Sambuc.\" For the
1892c96f054SLionel Sambuc.\" .Cm B
1902c96f054SLionel Sambuc.\" format, backslash-escape sequences are expanded first;
1912c96f054SLionel Sambuc.It Cm \&\-
1922c96f054SLionel SambucA minus sign
1932c96f054SLionel Sambuc.Sq \-
1942c96f054SLionel Sambucwhich specifies
1952c96f054SLionel Sambuc.Em left adjustment
1962c96f054SLionel Sambucof the output in the indicated field;
1972c96f054SLionel Sambuc.It Cm \&+
1982c96f054SLionel SambucA
1992c96f054SLionel Sambuc.Sq \&+
2002c96f054SLionel Sambuccharacter specifying that there should always be
2012c96f054SLionel Sambuca sign placed before the number when using signed formats.
2022c96f054SLionel Sambuc.It Sq \&\ \&
2032c96f054SLionel SambucA space specifying that a blank should be left before a positive number
2042c96f054SLionel Sambucfor a signed format.
2052c96f054SLionel SambucA
2062c96f054SLionel Sambuc.Sq \&+
2072c96f054SLionel Sambucoverrides a space if both are used;
2082c96f054SLionel Sambuc.It Cm \&0
2092c96f054SLionel SambucA zero `0' character indicating that zero-padding should be used
2102c96f054SLionel Sambucrather than blank-padding.
2112c96f054SLionel SambucA
2122c96f054SLionel Sambuc.Sq \-
2132c96f054SLionel Sambucoverrides a
2142c96f054SLionel Sambuc.Sq \&0
2152c96f054SLionel Sambucif both are used;
2162c96f054SLionel Sambuc.El
2172c96f054SLionel Sambuc.It Field Width :
2182c96f054SLionel SambucAn optional digit string specifying a
2192c96f054SLionel Sambuc.Em field width ;
2202c96f054SLionel Sambucif the output string has fewer characters than the field width it will
2212c96f054SLionel Sambucbe blank-padded on the left (or right, if the left-adjustment indicator
2222c96f054SLionel Sambuchas been given) to make up the field width (note that a leading zero
2232c96f054SLionel Sambucis a flag, but an embedded zero is part of a field width);
2242c96f054SLionel Sambuc.It Precision :
2252c96f054SLionel SambucAn optional period,
2262c96f054SLionel Sambuc.Sq Cm \&. ,
2272c96f054SLionel Sambucfollowed by an optional digit string giving a
2282c96f054SLionel Sambuc.Em precision
2292c96f054SLionel Sambucwhich specifies the number of digits to appear after the decimal point,
2302c96f054SLionel Sambucfor
2312c96f054SLionel Sambuc.Cm e
2322c96f054SLionel Sambucand
2332c96f054SLionel Sambuc.Cm f
2342c96f054SLionel Sambucformats, or the maximum number of characters to be printed
2352c96f054SLionel Sambucfrom a string
2362c96f054SLionel Sambuc.Sm off
2372c96f054SLionel Sambuc.Pf ( Cm b ,
2382c96f054SLionel Sambuc.Sm on
2392c96f054SLionel Sambuc.Cm B ,
2402c96f054SLionel Sambucand
2412c96f054SLionel Sambuc.Cm s
2422c96f054SLionel Sambucformats); if the digit string is missing, the precision is treated
2432c96f054SLionel Sambucas zero;
2442c96f054SLionel Sambuc.It Format :
2452c96f054SLionel SambucA character which indicates the type of format to use (one of
2462c96f054SLionel Sambuc.Cm diouxXfwEgGbBcs ) .
2472c96f054SLionel Sambuc.El
2482c96f054SLionel Sambuc.Pp
2492c96f054SLionel SambucA field width or precision may be
2502c96f054SLionel Sambuc.Sq Cm \&*
2512c96f054SLionel Sambucinstead of a digit string.
2522c96f054SLionel SambucIn this case an
2532c96f054SLionel Sambuc.Ar argument
2542c96f054SLionel Sambucsupplies the field width or precision.
2552c96f054SLionel Sambuc.Pp
2562c96f054SLionel SambucThe format characters and their meanings are:
2572c96f054SLionel Sambuc.Bl -tag -width Fl
2582c96f054SLionel Sambuc.It Cm diouXx
2592c96f054SLionel SambucThe
2602c96f054SLionel Sambuc.Ar argument
2612c96f054SLionel Sambucis printed as a signed decimal (d or i), unsigned octal, unsigned decimal,
2622c96f054SLionel Sambucor unsigned hexadecimal (X or x), respectively.
2632c96f054SLionel Sambuc.It Cm f
2642c96f054SLionel SambucThe
2652c96f054SLionel Sambuc.Ar argument
2662c96f054SLionel Sambucis printed in the style
2672c96f054SLionel Sambuc.Sm off
2682c96f054SLionel Sambuc.Pf [\-]ddd Cm \&. No ddd
2692c96f054SLionel Sambuc.Sm on
2702c96f054SLionel Sambucwhere the number of d's
2712c96f054SLionel Sambucafter the decimal point is equal to the precision specification for
2722c96f054SLionel Sambucthe argument.
2732c96f054SLionel SambucIf the precision is missing, 6 digits are given; if the precision
2742c96f054SLionel Sambucis explicitly 0, no digits and no decimal point are printed.
2752c96f054SLionel Sambuc.It Cm eE
2762c96f054SLionel SambucThe
2772c96f054SLionel Sambuc.Ar argument
2782c96f054SLionel Sambucis printed in the style
2792c96f054SLionel Sambuc.Sm off
2802c96f054SLionel Sambuc.Pf [\-]d Cm \&. No ddd Cm e No \*(Pmdd
2812c96f054SLionel Sambuc.Sm on
2822c96f054SLionel Sambucwhere there
2832c96f054SLionel Sambucis one digit before the decimal point and the number after is equal to
2842c96f054SLionel Sambucthe precision specification for the argument; when the precision is
2852c96f054SLionel Sambucmissing, 6 digits are produced.
2862c96f054SLionel SambucAn upper-case E is used for an
2872c96f054SLionel Sambuc.Sq E
2882c96f054SLionel Sambucformat.
2892c96f054SLionel Sambuc.It Cm gG
2902c96f054SLionel SambucThe
2912c96f054SLionel Sambuc.Ar argument
2922c96f054SLionel Sambucis printed in style
2932c96f054SLionel Sambuc.Cm f
2942c96f054SLionel Sambucor in style
2952c96f054SLionel Sambuc.Cm e
2962c96f054SLionel Sambuc.Pq Cm E
2972c96f054SLionel Sambucwhichever gives full precision in minimum space.
2982c96f054SLionel Sambuc.It Cm b
2992c96f054SLionel SambucCharacters from the string
3002c96f054SLionel Sambuc.Ar argument
3012c96f054SLionel Sambucare printed with backslash-escape sequences expanded.
3022c96f054SLionel Sambuc.Pp
3032c96f054SLionel SambucThe following additional backslash-escape sequences are supported:
3042c96f054SLionel Sambuc.Bl -tag -width Ds
3052c96f054SLionel Sambuc.It Cm \ec
3062c96f054SLionel SambucCauses
3072c96f054SLionel Sambuc.Nm
3082c96f054SLionel Sambucto ignore any remaining characters in the string operand containing it,
3092c96f054SLionel Sambucany remaining string operands, and any additional characters in
3102c96f054SLionel Sambucthe format operand.
3112c96f054SLionel Sambuc.It Cm \e0 Ns Ar num
3122c96f054SLionel SambucWrite an 8\-bit character whose
3132c96f054SLionel Sambuc.Tn ASCII
3142c96f054SLionel Sambucvalue is the 1\-, 2\-, or 3\-digit
3152c96f054SLionel Sambucoctal number
3162c96f054SLionel Sambuc.Ar num .
3172c96f054SLionel Sambuc.It Cm \e^ Ns Ar c
3182c96f054SLionel SambucWrite the control character
3192c96f054SLionel Sambuc.Ar c .
3202c96f054SLionel SambucGenerates characters `\e000' through `\e037`, and `\e177' (from `\e^?').
3212c96f054SLionel Sambuc.It Cm \eM\- Ns Ar c
3222c96f054SLionel SambucWrite the character
3232c96f054SLionel Sambuc.Ar c
3242c96f054SLionel Sambucwith the 8th bit set.
3252c96f054SLionel SambucGenerates characters `\e241' through `\e376`.
3262c96f054SLionel Sambuc.It Cm \eM^ Ns Ar c
3272c96f054SLionel SambucWrite the control character
3282c96f054SLionel Sambuc.Ar c
3292c96f054SLionel Sambucwith the 8th bit set.
3302c96f054SLionel SambucGenerates characters `\e200' through `\e237`, and `\e377' (from `\eM^?').
3312c96f054SLionel Sambuc.El
3322c96f054SLionel Sambuc.It Cm B
3332c96f054SLionel SambucCharacters from the string
3342c96f054SLionel Sambuc.Ar argument
3352c96f054SLionel Sambucare printed with unprintable characters backslash-escaped using the
3362c96f054SLionel Sambuc.Sm off
3372c96f054SLionel Sambuc.Pf ` Cm \e Ar c No ',
3382c96f054SLionel Sambuc.Pf ` Cm \e^ Ar c No ',
3392c96f054SLionel Sambuc.Pf ` Cm \eM\- Ar c No '
3402c96f054SLionel Sambucor
3412c96f054SLionel Sambuc.Pf ` Cm \eM^ Ar c No ',
3422c96f054SLionel Sambuc.Sm on
3432c96f054SLionel Sambucformats described above.
3442c96f054SLionel Sambuc.It Cm c
3452c96f054SLionel SambucThe first character of
3462c96f054SLionel Sambuc.Ar argument
3472c96f054SLionel Sambucis printed.
3482c96f054SLionel Sambuc.It Cm s
3492c96f054SLionel SambucCharacters from the string
3502c96f054SLionel Sambuc.Ar argument
3512c96f054SLionel Sambucare printed until the end is reached or until the number of characters
3522c96f054SLionel Sambucindicated by the precision specification is reached; if the
3532c96f054SLionel Sambucprecision is omitted, all characters in the string are printed.
3542c96f054SLionel Sambuc.It Cm \&%
3552c96f054SLionel SambucPrint a `%'; no argument is used.
3562c96f054SLionel Sambuc.El
3572c96f054SLionel Sambuc.Pp
3582c96f054SLionel SambucIn no case does a non-existent or small field width cause truncation of
3592c96f054SLionel Sambuca field; padding takes place only if the specified field width exceeds
3602c96f054SLionel Sambucthe actual width.
3612c96f054SLionel Sambuc.Sh EXIT STATUS
362*0a6a1f1dSLionel Sambuc.Ex -std
3632c96f054SLionel Sambuc.Sh SEE ALSO
3642c96f054SLionel Sambuc.Xr echo 1 ,
3652c96f054SLionel Sambuc.Xr printf 3 ,
3662c96f054SLionel Sambuc.Xr vis 3 ,
3672c96f054SLionel Sambuc.Xr printf 9
3682c96f054SLionel Sambuc.Sh STANDARDS
3692c96f054SLionel SambucThe
3702c96f054SLionel Sambuc.Nm
3712c96f054SLionel Sambucutility conforms to
3722c96f054SLionel Sambuc.St -p1003.1-2001 .
3732c96f054SLionel Sambuc.Pp
3742c96f054SLionel SambucSupport for the floating point formats and `*' as a field width and precision
3752c96f054SLionel Sambucare optional in POSIX.
3762c96f054SLionel Sambuc.Pp
3772c96f054SLionel SambucThe behaviour of the %B format and the \e', \e", \exxx, \ee and
3782c96f054SLionel Sambuc\e[M][\-|^]c escape sequences are undefined in POSIX.
3792c96f054SLionel Sambuc.Sh BUGS
3802c96f054SLionel SambucSince the floating point numbers are translated from
3812c96f054SLionel Sambuc.Tn ASCII
3822c96f054SLionel Sambucto floating-point and
3832c96f054SLionel Sambucthen back again, floating-point precision may be lost.
3842c96f054SLionel Sambuc.Pp
3852c96f054SLionel SambucHexadecimal character constants are restricted to, and should be specified
3862c96f054SLionel Sambucas, two character constants.
3872c96f054SLionel SambucThis is contrary to the ISO C standard but
3882c96f054SLionel Sambucdoes guarantee detection of the end of the constant.
3892c96f054SLionel Sambuc.Sh NOTES
3902c96f054SLionel SambucAll formats which treat the
3912c96f054SLionel Sambuc.Ar argument
3922c96f054SLionel Sambucas a number first convert the
3932c96f054SLionel Sambuc.Ar argument
3942c96f054SLionel Sambucfrom its external representation as a character string
3952c96f054SLionel Sambucto an internal numeric representation, and then apply the
3962c96f054SLionel Sambucformat to the internal numeric representation, producing
3972c96f054SLionel Sambucanother external character string representation.
3982c96f054SLionel SambucOne might expect the
3992c96f054SLionel Sambuc.Cm \&%c
4002c96f054SLionel Sambucformat to do likewise, but in fact it does not.
4012c96f054SLionel Sambuc.Pp
4022c96f054SLionel SambucTo convert a string representation of a decimal, octal, or hexadecimal
4032c96f054SLionel Sambucnumber into the corresponding character, two nested
4042c96f054SLionel Sambuc.Nm
4052c96f054SLionel Sambucinvocations may be used, in which the inner invocation
4062c96f054SLionel Sambucconverts the input to an octal string, and the outer
4072c96f054SLionel Sambucinvocation uses the octal string as part of a format.
4082c96f054SLionel SambucFor example, the following command outputs the character whose code
4092c96f054SLionel Sambucis 0x0A, which is a newline in ASCII:
4102c96f054SLionel Sambuc.Pp
4112c96f054SLionel Sambuc.Dl printf \&"$(printf \&"\e\e%o" \&"0x0A")"
412