Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

After Goliath's defeat, giants ceased to command respect. -- Freeman Dyson


devel / comp.lang.awk / GAWK: Converting a number to a string (the hard way!) - Discuss!

SubjectAuthor
* GAWK: Converting a number to a string (the hard way!) - Discuss!Kenny McCormack
+* Re: GAWK: Converting a number to a string (the hard way!) - Discuss!Janis Papanagnou
|`- Re: GAWK: Converting a number to a string (the hard way!) - Discuss!Janis Papanagnou
`* Re: GAWK: Converting a number to a string (the hard way!) - Discuss!Janis Papanagnou
 `* Re: GAWK: Converting a number to a string (the hard way!) - Discuss!Kenny McCormack
  `* Re: GAWK: Converting a number to a string (the hard way!) - Discuss!Janis Papanagnou
   +- Re: GAWK: Converting a number to a string (the hard way!) - Discuss!Kpop 2GM
   `- Re: GAWK: Converting a number to a string (the hard way!) - Discuss!Kpop 2GM

1
GAWK: Converting a number to a string (the hard way!) - Discuss!

<srpa3i$33lrs$1@news.xmission.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=979&group=comp.lang.awk#979

  copy link   Newsgroups: comp.lang.awk
Path: i2pn2.org!rocksolid2!news.neodome.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gazelle@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.lang.awk
Subject: GAWK: Converting a number to a string (the hard way!) - Discuss!
Date: Thu, 13 Jan 2022 13:40:02 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <srpa3i$33lrs$1@news.xmission.com>
Injection-Date: Thu, 13 Jan 2022 13:40:02 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="3266428"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Thu, 13 Jan 2022 13:40 UTC

I have a situation where I need to convert a number (a 32 bit integer) to a
4 byte string - i.e., the internal representation of that 32 bit number as 4
consecutive bytes. This is so that I can pass (the address of) that string
to a low-level routine that wants (basically) an "int *" value.

I managed to get it working, using the following function:

# This assumes 32 bit ints on a little-endian architecture.
# Call as: str = encode(number)
function encode(n, i,s) {
s = sprintf("%c",n)
for (i=1; i<4; i++)
s = s sprintf("%c",rshift(n,i*8))
return s
}

This works, but I'm wondering if there is a better/more efficient/cuter way
to do it. Please discuss.

Note, BTW, that I have verified that when you printf with %c, it only uses
the low 8 bits of the number you pass in. So, you don't need to do any
"AND"ing.

--
Modern Christian: Someone who can take time out from using Leviticus
to defend homophobia and Exodus to plaster the Ten Commandments on
every school and courthouse to claim that the Old Testament is merely
"ancient laws" that "only applies to Jews".

Re: GAWK: Converting a number to a string (the hard way!) - Discuss!

<srpksc$fbd$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=980&group=comp.lang.awk#980

  copy link   Newsgroups: comp.lang.awk
Path: i2pn2.org!i2pn.org!aioe.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou@hotmail.com (Janis Papanagnou)
Newsgroups: comp.lang.awk
Subject: Re: GAWK: Converting a number to a string (the hard way!) - Discuss!
Date: Thu, 13 Jan 2022 17:43:56 +0100
Organization: A noiseless patient Spider
Lines: 65
Message-ID: <srpksc$fbd$1@dont-email.me>
References: <srpa3i$33lrs$1@news.xmission.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 13 Jan 2022 16:43:56 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="79f9d86599c5d8b69ed0f75cb3837721";
logging-data="15725"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/euNhmCHF/4YAPK5jo6V5F"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:+Tv58pWZlgutpSTU5j7Fob93C3Y=
In-Reply-To: <srpa3i$33lrs$1@news.xmission.com>
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Thu, 13 Jan 2022 16:43 UTC

On 13.01.2022 14:40, Kenny McCormack wrote:
> I have a situation where I need to convert a number (a 32 bit integer) to a
> 4 byte string - i.e., the internal representation of that 32 bit number as 4
> consecutive bytes. This is so that I can pass (the address of) that string
> to a low-level routine that wants (basically) an "int *" value.
>
> I managed to get it working, using the following function:
>
> # This assumes 32 bit ints on a little-endian architecture.
> # Call as: str = encode(number)
> function encode(n, i,s) {
> s = sprintf("%c",n)
> for (i=1; i<4; i++)
> s = s sprintf("%c",rshift(n,i*8))
> return s
> }
>
> This works, but I'm wondering if there is a better/more efficient/cuter way
> to do it. Please discuss.

Well, the task has a few standard data splitting steps that you
implemented in a straightforward way. Effectively it's basically
fine and minimal, I'd say.

Just one thought one might want to take into consideration...

Recursive counterparts of iterative functions are typically clearer,
since they don't require explicit variables to be defined and assigned.
(And I presume that the function call overhead is insignificant here.)
Such a function may look as simple as

function encode(i,n) {
if (i>0) {
printf("%c",n)
encode(i-1,rshift(n,8))
}
}

and is called with an additional argument indicating the number of
octets e.g., encode(4, 0x41424344) or encode(4, 1094861636) to
produce "DCBA".

To hide function parameters like the "4" there's then often a wrapper
function defined if one doesn't need to control the number of octets
function e(n) { encode(4,n) }
which of course "complicates" the matter again a bit (one may think).

But keeping that parameter allows also less function calls in case
you want to just extract, say, 2 or 3 octets from that number, as in
encode(3, 0x41424344) which will produce the same result as the call
encode(3, 0x00424344) .

Whether the clearness of recursion is "better" or "cuter" certainly
lies in the eye of the beholder. While I have to admit to rarely use
recursion, in most cases I always admire these recursive solutions
once I've written them down and see how perfect they are as a concept.

Janis

>
> Note, BTW, that I have verified that when you printf with %c, it only uses
> the low 8 bits of the number you pass in. So, you don't need to do any
> "AND"ing.
>

Re: GAWK: Converting a number to a string (the hard way!) - Discuss!

<srpmau$qjl$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=981&group=comp.lang.awk#981

  copy link   Newsgroups: comp.lang.awk
Path: i2pn2.org!i2pn.org!news.swapon.de!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou@hotmail.com (Janis Papanagnou)
Newsgroups: comp.lang.awk
Subject: Re: GAWK: Converting a number to a string (the hard way!) - Discuss!
Date: Thu, 13 Jan 2022 18:08:46 +0100
Organization: A noiseless patient Spider
Lines: 84
Message-ID: <srpmau$qjl$1@dont-email.me>
References: <srpa3i$33lrs$1@news.xmission.com> <srpksc$fbd$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 13 Jan 2022 17:08:46 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="79f9d86599c5d8b69ed0f75cb3837721";
logging-data="27253"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Bw5DHtLbt4R74m7W+mGJ1"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:r7PBi6BiKpkZW1IioKT55QrwVOA=
In-Reply-To: <srpksc$fbd$1@dont-email.me>
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Thu, 13 Jan 2022 17:08 UTC

On 13.01.2022 17:43, Janis Papanagnou wrote:
> On 13.01.2022 14:40, Kenny McCormack wrote:
>> I have a situation where I need to convert a number (a 32 bit integer) to a
>> 4 byte string - i.e., the internal representation of that 32 bit number as 4
>> consecutive bytes. This is so that I can pass (the address of) that string
>> to a low-level routine that wants (basically) an "int *" value.
>>
>> I managed to get it working, using the following function:
>>
>> # This assumes 32 bit ints on a little-endian architecture.
>> # Call as: str = encode(number)
>> function encode(n, i,s) {
>> s = sprintf("%c",n)
>> for (i=1; i<4; i++)
>> s = s sprintf("%c",rshift(n,i*8))
>> return s
>> }
>>
>> This works, but I'm wondering if there is a better/more efficient/cuter way
>> to do it. Please discuss.
>
> Well, the task has a few standard data splitting steps that you
> implemented in a straightforward way. Effectively it's basically
> fine and minimal, I'd say.
>
> Just one thought one might want to take into consideration...
>
> Recursive counterparts of iterative functions are typically clearer,
> since they don't require explicit variables to be defined and assigned.
> (And I presume that the function call overhead is insignificant here.)
> Such a function may look as simple as
>
> function encode(i,n) {
> if (i>0) {
> printf("%c",n)
> encode(i-1,rshift(n,8))
> }
> }

This function will just print the result, but I notice that the OP
wanted them in a string. So here's a recursive variant

function encode(i,n) {
if (i>0)
return sprintf("%c",n) encode(i-1,rshift(n,8))
}

Or if the reverse octet order is desired, just change the order of
the concatenation

return encode(i-1,rshift(n,8)) sprintf("%c",n)

Note: I omitted the 'i<=0' case since awk seems to create an empty
value as default return value.

>
> and is called with an additional argument indicating the number of
> octets e.g., encode(4, 0x41424344) or encode(4, 1094861636) to
> produce "DCBA".
>
> To hide function parameters like the "4" there's then often a wrapper
> function defined if one doesn't need to control the number of octets
> function e(n) { encode(4,n) }
> which of course "complicates" the matter again a bit (one may think).
>
> But keeping that parameter allows also less function calls in case
> you want to just extract, say, 2 or 3 octets from that number, as in
> encode(3, 0x41424344) which will produce the same result as the call
> encode(3, 0x00424344) .
>
> Whether the clearness of recursion is "better" or "cuter" certainly
> lies in the eye of the beholder. While I have to admit to rarely use
> recursion, in most cases I always admire these recursive solutions
> once I've written them down and see how perfect they are as a concept.
>
> Janis
>
>>
>> Note, BTW, that I have verified that when you printf with %c, it only uses
>> the low 8 bits of the number you pass in. So, you don't need to do any
>> "AND"ing.
>>
>

Re: GAWK: Converting a number to a string (the hard way!) - Discuss!

<srr71o$ll4$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=984&group=comp.lang.awk#984

  copy link   Newsgroups: comp.lang.awk
Path: i2pn2.org!i2pn.org!aioe.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou@hotmail.com (Janis Papanagnou)
Newsgroups: comp.lang.awk
Subject: Re: GAWK: Converting a number to a string (the hard way!) - Discuss!
Date: Fri, 14 Jan 2022 08:00:08 +0100
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <srr71o$ll4$1@dont-email.me>
References: <srpa3i$33lrs$1@news.xmission.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 14 Jan 2022 07:00:08 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="a870b32ab8ee0054ceb7dd078a69656e";
logging-data="22180"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19YVxcDATMbsCeNU2IRfM2s"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:g+zTZtXsEDz97AipFnr3D40f720=
In-Reply-To: <srpa3i$33lrs$1@news.xmission.com>
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Fri, 14 Jan 2022 07:00 UTC

On 13.01.2022 14:40, Kenny McCormack wrote:
>
> Note, BTW, that I have verified that when you printf with %c, it only uses
> the low 8 bits of the number you pass in. So, you don't need to do any
> "AND"ing.

I also used that assumption in my code upthread but forgot to point
out that this is not reliable or is generally even not true because
that depends on the locale that you have set. Just two samples from
a Unix context...

$ printf "%s\n" 65 65601 | LC_ALL=C awk '{printf "%c\n", $0}' | od -c -tx1
0000000 A \n A \n
41 0a 41 0a

$ printf "%s\n" 65 65601 | LC_ALL=C.UTF-8 awk '{printf "%c\n", $0}' | od
-c -tx1
0000000 A \n 360 220 201 201 \n
41 0a f0 90 81 81 0a

So depending on context and requirements the AND'ing might still be
necessary or the locale explicitly adjusted (as in the sample here).

Janis

Re: GAWK: Converting a number to a string (the hard way!) - Discuss!

<srs1cq$35bur$1@news.xmission.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=986&group=comp.lang.awk#986

  copy link   Newsgroups: comp.lang.awk
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gazelle@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.lang.awk
Subject: Re: GAWK: Converting a number to a string (the hard way!) - Discuss!
Date: Fri, 14 Jan 2022 14:29:46 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <srs1cq$35bur$1@news.xmission.com>
References: <srpa3i$33lrs$1@news.xmission.com> <srr71o$ll4$1@dont-email.me>
Injection-Date: Fri, 14 Jan 2022 14:29:46 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="3321819"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Fri, 14 Jan 2022 14:29 UTC

In article <srr71o$ll4$1@dont-email.me>,
Janis Papanagnou <janis_papanagnou@hotmail.com> wrote:
>On 13.01.2022 14:40, Kenny McCormack wrote:
>>
>> Note, BTW, that I have verified that when you printf with %c, it only uses
>> the low 8 bits of the number you pass in. So, you don't need to do any
>> "AND"ing.
>
>I also used that assumption in my code upthread but forgot to point
>out that this is not reliable or is generally even not true because
>that depends on the locale that you have set. Just two samples from
>a Unix context...

I get it, but I am not too concerned about it. Since this method already
assumes 32 bits and little-endian, I would just add to the list of
assumptions: "No goofy locale settings". I.e., it works in the C locale.

In fact, on almost all of my machines, I put code in my startup files to
unset any locale related environment variables and/or set them to just "C".
Makes life a lot more predictable.

BTW(1), this is sort of the genesis of this thread. I was looking for a more
straightforward way to do it - that wouldn't depend on so many simplifying
assumptions in order to work. Seems there ought to be a simpler way to
just put 4 bytes into a string. That's what I was hoping for...

BTW(2), TAWK has this covered - there are functions "pack" and "unpack"
specifically for this sort of thing - packing values into (and unpacking
out of) strings that act as structs that you pass to low-level routines.
Of course, the fact that TAWK directly supports access to low-level
routines obliges it to provide these functionalities. Native GAWK does not
(yet) provide access to low-level stuff. The dialect of GAWK that I
program in, does.

Of course, I could make this whole problem go away by writing yet another
extension lib to do it - but I was trying to avoid doing that.

--
The randomly chosen signature file that would have appeared here is more than 4
lines long. As such, it violates one or more Usenet RFCs. In order to remain
in compliance with said RFCs, the actual sig can be found at the following URL:
http://user.xmission.com/~gazelle/Sigs/Infallibility

Re: GAWK: Converting a number to a string (the hard way!) - Discuss!

<srt7r4$4ab$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=987&group=comp.lang.awk#987

  copy link   Newsgroups: comp.lang.awk
Path: i2pn2.org!i2pn.org!news.swapon.de!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou@hotmail.com (Janis Papanagnou)
Newsgroups: comp.lang.awk
Subject: Re: GAWK: Converting a number to a string (the hard way!) - Discuss!
Date: Sat, 15 Jan 2022 02:25:56 +0100
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <srt7r4$4ab$1@dont-email.me>
References: <srpa3i$33lrs$1@news.xmission.com> <srr71o$ll4$1@dont-email.me>
<srs1cq$35bur$1@news.xmission.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 15 Jan 2022 01:25:56 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="3dca7743c88a5ef03894643f68e296a9";
logging-data="4427"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/xqEQ20quLERM4dG8EsKzQ"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:KpOu6N0TAeWUArkWP46Ew6td6yo=
In-Reply-To: <srs1cq$35bur$1@news.xmission.com>
 by: Janis Papanagnou - Sat, 15 Jan 2022 01:25 UTC

On 14.01.2022 15:29, Kenny McCormack wrote:
>
> I get it, but I am not too concerned about it. Since this method already
> assumes 32 bits and little-endian, I would just add to the list of
> assumptions: "No goofy locale settings". I.e., it works in the C locale.

Fair enough. For others here it might be a fact to consider to not
get surprised.

>
> Of course, I could make this whole problem go away by writing yet another
> extension lib to do it - but I was trying to avoid doing that.

And that (with GNU Awk) would be the way to go.

Janis

Re: GAWK: Converting a number to a string (the hard way!) - Discuss!

<1a891baf-fbb2-4e7c-9d80-a1e92e9dbe1fn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=990&group=comp.lang.awk#990

  copy link   Newsgroups: comp.lang.awk
X-Received: by 2002:a05:622a:1c3:: with SMTP id t3mr2473264qtw.564.1642415863804;
Mon, 17 Jan 2022 02:37:43 -0800 (PST)
X-Received: by 2002:a25:2e50:: with SMTP id b16mr7863617ybn.323.1642415863662;
Mon, 17 Jan 2022 02:37:43 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.awk
Date: Mon, 17 Jan 2022 02:37:43 -0800 (PST)
In-Reply-To: <srt7r4$4ab$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2603:7000:3c3d:41c0:0:0:0:3c3;
posting-account=n74spgoAAAAZZyBGGjbj9G0N4Q659lEi
NNTP-Posting-Host: 2603:7000:3c3d:41c0:0:0:0:3c3
References: <srpa3i$33lrs$1@news.xmission.com> <srr71o$ll4$1@dont-email.me>
<srs1cq$35bur$1@news.xmission.com> <srt7r4$4ab$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <1a891baf-fbb2-4e7c-9d80-a1e92e9dbe1fn@googlegroups.com>
Subject: Re: GAWK: Converting a number to a string (the hard way!) - Discuss!
From: jason.cy.kwan@gmail.com (Kpop 2GM)
Injection-Date: Mon, 17 Jan 2022 10:37:43 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 23
 by: Kpop 2GM - Mon, 17 Jan 2022 10:37 UTC

On Friday, January 14, 2022 at 8:26:02 PM UTC-5, Janis Papanagnou wrote:
> On 14.01.2022 15:29, Kenny McCormack wrote:
> >
> > I get it, but I am not too concerned about it. Since this method already
> > assumes 32 bits and little-endian, I would just add to the list of
> > assumptions: "No goofy locale settings". I.e., it works in the C locale.
> Fair enough. For others here it might be a fact to consider to not
> get surprised.
> >
> > Of course, I could make this whole problem go away by writing yet another
> > extension lib to do it - but I was trying to avoid doing that.
> And that (with GNU Awk) would be the way to go.
>
> Janis

if u wanna make it consistent regardless of locale settings , just add a large multiple of 256 that's larger than 0x10FFFF -

LC_ALL="UTF-8" gawk -e 'BEGIN { printf("%c",65601+8^7) }' | od -baxco
0000000 101
A
0041
A
000101
0000001

Re: GAWK: Converting a number to a string (the hard way!) - Discuss!

<e53ab359-745f-4a22-98b5-6501f18dfe33n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=991&group=comp.lang.awk#991

  copy link   Newsgroups: comp.lang.awk
X-Received: by 2002:a05:6214:238e:: with SMTP id fw14mr17874614qvb.86.1642415983393;
Mon, 17 Jan 2022 02:39:43 -0800 (PST)
X-Received: by 2002:a5b:f89:: with SMTP id q9mr26587866ybh.452.1642415983164;
Mon, 17 Jan 2022 02:39:43 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.awk
Date: Mon, 17 Jan 2022 02:39:42 -0800 (PST)
In-Reply-To: <srt7r4$4ab$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2603:7000:3c3d:41c0:0:0:0:3c3;
posting-account=n74spgoAAAAZZyBGGjbj9G0N4Q659lEi
NNTP-Posting-Host: 2603:7000:3c3d:41c0:0:0:0:3c3
References: <srpa3i$33lrs$1@news.xmission.com> <srr71o$ll4$1@dont-email.me>
<srs1cq$35bur$1@news.xmission.com> <srt7r4$4ab$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <e53ab359-745f-4a22-98b5-6501f18dfe33n@googlegroups.com>
Subject: Re: GAWK: Converting a number to a string (the hard way!) - Discuss!
From: jason.cy.kwan@gmail.com (Kpop 2GM)
Injection-Date: Mon, 17 Jan 2022 10:39:43 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 16
 by: Kpop 2GM - Mon, 17 Jan 2022 10:39 UTC

if u wanna make it consistent regardless of locale settings, add a very large multiple of 256 above 0x10FFFF :

LC_ALL="UTF-8" gawk -e 'BEGIN { printf("%c",65601+8^7) }' | od -baxco
0000000 101
A
0041
A
000101
0000001

% LC_ALL="UTF-8" gawk -e 'BEGIN { printf("%c",65601) }' | od -baxco
0000000 360 220 201 201
? 90 81 81
90f0 8181
360 220 201 201
110360 100601
0000004

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor