From mboxrd@z Thu Jan 1 00:00:00 1970 From: dexen deVries To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Date: Tue, 17 Sep 2013 19:12:26 +0200 Message-ID: <18176302.9ISQnDhI0I@coil> User-Agent: KMail/4.10.5 (Linux/3.11.0-rc3-l52; KDE/4.10.5; x86_64; ; ) In-Reply-To: References: <1482429.KLDYROpnPh@coil> <20130917140311.Horde.h37nmc23IQ06O84zHmBqzw1@ssl.eumx.net> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Subject: Re: [9fans] how to output NUL byte from awk? Topicbox-Message-UUID: 80480588-ead8-11e9-9d60-3106f5b1d025 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 : > > > awk(1) says, ``[s]tring constants are quoted " ", with the usual = C > > > escapes > > > recognized within.'', but \0 seems to terminate internal string > > > reprezentation... > > >=20 > > > so how do i output a real NUL byte? > >=20 > > Does printf not do this? >=20 > 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 printf "%c", 0 --=20 dexen deVries [[[=E2=86=93][=E2=86=92]]] Take care of the luxuries and the necessities will take care of themsel= ves. -- L. Long