Path: ...!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Chris Ahlstrom Newsgroups: comp.os.linux.misc Subject: Re: The joy of octal Date: Tue, 12 Nov 2024 07:29:12 -0500 Organization: None Lines: 52 Message-ID: References: <20241111090306.0000385d@gmail.com> Reply-To: OFeem1987@teleworm.us MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Tue, 12 Nov 2024 13:29:16 +0100 (CET) Injection-Info: dont-email.me; posting-host="3090a65867b94aed9d2c56630aa2594e"; logging-data="1679333"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+wT0WvObh3T6LwDOGa/J5e" User-Agent: slrn/1.0.3 (Linux) Cancel-Lock: sha1:NH0XW5cf+PT1IBf7kGjaslsMg04= X-Face: 63n<76,LYJQ2m#'5YL#.T95xqyPiG`ffIP70tN+j"(&@6(4l\7uL)2+/-r0)/9SjZ`qw= Njn mr93Xrerx}aQG-Ap5IHn"xe;`5:pp"$RH>Kx_ngWw%c\+6qSg!q"41n2[.N/;Pu6q8?+Poz~e A9? $6_R7cm.l!s8]yfv7x+-FYQ|/k X-User-Agent: Microsoft Outl00k, Usenet K00k Editions X-Mutt: The most widely-used MUA X-Slrn: Why use anything else? Bytes: 2904 Louis Krupp wrote this post while blinking in Morse code: > On 11/11/2024 1:58 PM, Chris Ahlstrom wrote: >> John Ames wrote this post while blinking in Morse code: >> >>> On Sat, 9 Nov 2024 09:36:58 -0500 >>> Chris Ahlstrom wrote: >>> >>>> 020111 067544 023556 020164 062556 062145 067040 020157 072163 062545 >>>> 065556 067151 020147 062550 060570 062544 064543 060555 020554 005012 >>> 041165 072040 073350 060564 020151 063040 074557 072447 071145 020167 >>> 071151 072151 067147 020146 071157 066400 060440 061151 063455 062556 >>> 062151 060556 020155 060543 064151 067145 027056 027077 >> Damn, I still haven't found a program that would easily reverse octal to a >> string. >> > > This is crude, but it seems to work for the post you're replying to, > with big-endian two-byte integers: > > === > #include > > int main(void) > { >     union { >         unsigned short s; >         char c[2]; >     } w; >     unsigned int wi; >     char junk; > >     while (scanf("%o%c", &wi, &junk) > 0) { >         w.s = wi; >         printf("%c%c", w.c[1], w.c[0]); >     } >     printf("\n"); > >     return 0; > } > === > > To read a sequence of two-byte octal little-endian integers, swap w.c[1] > and w.c[0]. Thanks! -- After all, what is your hosts' purpose in having a party? Surely not for you to enjoy yourself; if that were their sole purpose, they'd have simply sent champagne and women over to your place by taxi. -- P. J. O'Rourke