From: dexen deVries <dexen.devries@gmail.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: Re: [9fans] how to output NUL byte from awk?
Date: Tue, 17 Sep 2013 20:55:26 +0200 [thread overview]
Message-ID: <1610066.oU4p7CaOjH@potez> (raw)
In-Reply-To: <d1ad32e7589bccd0e90316978fcce125@ladd.quanstro.net>
On Tuesday 17 of September 2013 12:50:07 erik quanstrom wrote:
> On Tue Sep 17 10:04:20 EDT 2013, khm@sciops.net wrote:
> > Quoting dexen deVries <dexen.devries@gmail.com>:
> > > awk(1) says, ``[s]tring constants are quoted " ", with the usual C
> > > escapes
> > > recognized within.'', but \0 seems to terminate internal string
> > > reprezentation...
> > >
> > > so how do i output a real NUL byte?
> >
> > Does printf not do this?
>
> no, awk's printf does not do that:
> minooka; awk 'BEGIN{printf "%c", utf(0)}' | wc
> 0 0 0
> minooka; awk 'BEGIN{printf "%.5s", "12\034567890"}' | xd -1
> 0000000 31 32 1c 35 36
> minooka; awk 'BEGIN{printf "%.5s", "12\0\034567890"}' | xd -1
> 0000000 31 32
utf() is the problem, %c expect int, not string:
9 awk ' BEGIN { printf "%c", 0 } ' | 9 wc
0 1 1
9 awk ' BEGIN { printf "X%cX", 0 } ' | 9 xd
0000000 58005800
--
dx
next prev parent reply other threads:[~2013-09-17 18:55 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-17 13:47 dexen deVries
2013-09-17 14:03 ` Kurt H Maier
2013-09-17 14:36 ` dexen deVries
2013-09-17 16:50 ` erik quanstrom
2013-09-17 17:12 ` dexen deVries
2013-09-17 18:55 ` dexen deVries [this message]
2013-09-17 19:07 ` Kurt H Maier
2013-09-17 19:21 ` cinap_lenrek
2013-09-17 17:50 ` arnold
2013-09-18 7:24 ` Florian Limberger
2013-09-18 7:36 ` Bruce Ellis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1610066.oU4p7CaOjH@potez \
--to=dexen.devries@gmail.com \
--cc=9fans@9fans.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).