summaryrefslogtreecommitdiff
path: root/usr.bin/printf/printf.1
diff options
context:
space:
mode:
authorapb <apb@NetBSD.org>2008-05-06 12:01:35 +0000
committerapb <apb@NetBSD.org>2008-05-06 12:01:35 +0000
commit76807ad91ea3df4ac9d33d2826a22d9fc0c85fac (patch)
tree94f17b6b454c8dfc7488d573769899bf4c93f802 /usr.bin/printf/printf.1
parent2925cedf2672b64c751ca12bd2e9fee966476c59 (diff)
Add a note about the stupid behaviour of "%c" format.
Diffstat (limited to 'usr.bin/printf/printf.1')
-rw-r--r--usr.bin/printf/printf.127
1 files changed, 25 insertions, 2 deletions
diff --git a/usr.bin/printf/printf.1 b/usr.bin/printf/printf.1
index 408c260a757..758a3aca983 100644
--- a/usr.bin/printf/printf.1
+++ b/usr.bin/printf/printf.1
@@ -1,4 +1,4 @@
-.\" $NetBSD: printf.1,v 1.20 2003/08/07 11:15:32 agc Exp $
+.\" $NetBSD: printf.1,v 1.21 2008/05/06 12:01:35 apb Exp $
.\"
.\" Copyright (c) 1989, 1990, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -32,7 +32,7 @@
.\"
.\" from: @(#)printf.1 8.1 (Berkeley) 6/6/93
.\"
-.Dd November 5, 1993
+.Dd May 6, 2008
.Dt PRINTF 1
.Os
.Sh NAME
@@ -387,3 +387,26 @@ Hexadecimal character constants are restricted to, and should be specified
as, two character constants.
This is contrary to the ISO C standard but
does guarantee detection of the end of the constant.
+.Sh NOTES
+All formats which treat the
+.Ar argument
+as a number first convert the
+.Ar argument
+from its external representation as a character string
+to an internal numeric representation, and then apply the
+format to the internal numeric representation, producing
+another external character string representation.
+One might expect the
+.Cm \&%c
+format to do likewise, but in fact it does not.
+.Pp
+To convert a string representation of a decimal, octal, or hexadecimal
+number into the corresponding character, two nested
+.Nm
+invocations may be used, in which the inner invocation
+converts the input to an octal string, and the outer
+invocation uses the octal string as part of a format.
+For example, the following command outputs the character whose code
+is 0x0A, which is a newline in ASCII:
+.Pp
+.Dl printf \&"$(printf \&"\e\e%o" \&"0x0A")"