bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gawk] How to print an unsigned char?


From: Andrew J. Schorr
Subject: Re: [bug-gawk] How to print an unsigned char?
Date: Sun, 24 Feb 2019 18:07:22 -0500
User-agent: Mutt/1.5.21 (2010-09-15)

On Sun, Feb 24, 2019 at 02:40:54PM -0600, Peng Yu wrote:
> On 2/24/19, Eli Zaretskii <address@hidden> wrote:
> > [Please use Reply All, please don't take this off-list.]
> >
> >> From: Peng Yu <address@hidden>
> >> Date: Sun, 24 Feb 2019 12:11:45 -0600
> >>
> >> > Yes, don't use %c.
> >> How?
> >
> > It depends on what you want to accomplish.  Can you describe your
> > goal(s) in this matter?
> 
> As the title says "How to print an unsigned char?"

This can be done using the extension API. The get_file hook provides access to
the file descriptor via the returned awk_input_buf_t or awk_output_buf_t. The
select extension uses this in the "input_fd" and "output_fd" functions. So it
should be fairly simple to create an extension that provides access to the read
& write system calls for a gawk "file". We will eventually need this if anybody
wants to implement a socket library.

So it's simple: write a new gawk extension implementing read and write, and
then you can use those functions to do binary I/O. Or just use Python where the
file objects can be accessed through the high-level print function or the
low-level read and write methods.

Regards,
Andy



reply via email to

[Prev in Thread] Current Thread [Next in Thread]