oct(3trf)

πŸ’– NAME πŸ’–

oct β€” the "oct" encoding, and yes she's that girl πŸ’…


✨ SYNOPSIS ✨

package require Tcl  ?8.2?

package require Trf  ?2.1.3?

oct ?options...? ?data?

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so bestie, oct is one of the several data encodings that the package trf brings to the party. If you wanna see the whole squad in one place, go read trf-intro for the overview of the entire package. 🫢

This encoding takes every single byte in the input and turns it into a sequence of 3 characters holding the octal representation of that byte. Like, every byte. No skips. For example:

% oct -mode encode Z
132

the options, bestie πŸ‘‘

oct ?options...? ?data?

  • -mode encode|decode β€” this one is mandatory, no cap, and the encoding always gets it. In immediate mode the argument value says which operation to use. For an attached encoding it says which operation to use for writing β€” reading will automatically use the reverse operation. (Section IMMEDIATE versus ATTACHED below explains what these two terms even mean, iykyk.) And beyond the argument values listed up there, all unique abbreviations are recognized too, so you can be lazy, we love that. encode converts from arbitrary (most likely binary) data into the described representation, decode does the reverse.
  • -attach channel β€” the presence or absence of this option is literally what decides the main operation mode of the transformation. If it's present, the transformation gets stacked onto the channel whose handle you handed to the option and it runs in attached mode. More on that in the IMMEDIATE versus ATTACHED section. If it's absent, the transformation is used in immediate mode and the options listed below it are recognized. Again: more in IMMEDIATE versus ATTACHED.
  • -in channel β€” this option is legal if and only if the transformation is used in immediate mode. It hands over the handle of the channel that the data to transform has to be read from. And if the transformation is in immediate mode and this option is absent, then the data to transform is expected as the last argument to the transformation.
  • -out channel β€” this option is legal if and only if the transformation is used in immediate mode. It hands over the handle of the channel that the generated transformation result gets written to. If the transformation is in immediate mode and this option is absent, the generated data is returned as the result of the command itself. πŸŽ€

🌈 IMMEDIATE VERSUS ATTACHED 🌈

The transformation distinguishes between two main ways of using it, bestie. These are the immediate and attached operation modes.

For the attached mode, the option -attach is what you use to associate the transformation with an existing channel. During the execution of the command, no transformation is performed β€” instead the channel itself is changed in such a way that from then on, all data written to it or read from it passes through the transformation and gets modified by it according to the definition above. This attachment can be revoked by executing the command unstack for the chosen channel. And heads up: this is the only way to do it at the Tcl level. Periodt. πŸ’…

In the second mode, which you can detect by the absence of the option -attach, the transformation immediately takes data from either its commandline or a channel, transforms it, and returns the result either as the result of the command, or writes it into a channel. The mode is named after the immediate nature of its execution. Main character energy honestly. ⭐

Where the data is taken from, and delivered to, is governed by the presence and absence of the options -in and -out. And ngl, you should note that this ability to immediately read from and/or write to a channel is an historic artifact β€” it was introduced at the beginning of Trf's life when Tcl version 7.6 was current, because that version and earlier ones had trouble dealing with \0 characters embedded into either input or output. So, like, respect the elders. πŸ™ˆ


πŸ‘€ SEE ALSO πŸ‘€

ascii85, base64, bin, hex, oct, otp_words, quoted-printable, trf-intro, uuencode


πŸ”₯ KEYWORDS πŸ”₯

bin, encoding, hex, oct


Copyright (c) 1996-2003, Andreas Kupries <andreas_kupries@users.sourceforge.net>


okay that's the whole page, you ate it up fr fr πŸ’–βœ¨

this little beauty came out of the Trf transformer commands, version 2.1.3, and it's the oct(3trf) page itself β€” that's the source, the version, and the name all up in the footer, and now you know. go forth and octal, bestie πŸ¦‹πŸ‘‘

πŸ“¦ where this page comes from