bin(3trf)

πŸ’– bin β€” the "bin" encoding, bestie πŸ’–

okay so real quick, this is from the 3trf manual (that's the 3trf manual section, iykyk) and it's literally one of the little encoding girlies that live inside the Trf package. she's giving binary representation, but make it text. πŸ¦‹


✨ NAME ✨

bin β€” the Encoding "bin", periodt.


🌸 SYNOPSIS 🌸

package require Tcl  ?8.2?

package require Trf  ?2.1.3?

bin ?options...? ?data?

like, that's it. that's the whole vibe. πŸŽ€


πŸ’… DESCRIPTION πŸ’…

The command bin is one of several data encodings provided by the package trf. no cap β€” if you wanna see the whole squad, go read trf-intro for an overview of the entire package. πŸ‘‘

This encoding transforms every byte in the input into a sequence of 8 characters containing the binary representation of the byte. like, one single byte walks in, eight lil 0s and 1s walk out. iconic behavior honestly. for example:

% bin -mode encode Z
01011010

the way that Z just became 01011010?? ate. πŸ’…


πŸŽ€ bin ?options...? ?data? πŸŽ€ (the options section, bestie)

bin ?options...? ?data?
  • -mode encode|decode β€” this option has to be present and is always understood by the encoding. no skipping, she's mandatory fr fr.

for immediate mode, the argument value specifies the operation to use. for an attached encoding, it specifies the operation to use for writing. reading will automatically use the reverse operation. (see the section IMMEDIATE versus ATTACHED below for explanations of these two terms, because yes, we're getting into it. 🫢)

beyond the argument values listed above, all unique abbreviations are recognized too. so you can be lazy, she doesn't mind. 😌

encode converts from arbitrary (most likely binary) data into the described representation, decode does the reverse .

  • -attach channel β€” the presence/absence of this option determines the main operation mode of the transformation. it's giving mode selector.

if present, the transformation will be stacked onto the channel whose handle was given to the option and run in attached mode. more about this in the section IMMEDIATE versus ATTACHED.

if the option is absent, the transformation is used in immediate mode and the options listed below are recognized. more about this in the section IMMEDIATE versus ATTACHED.

  • -in channel β€” this options is legal if and only if the transformation is used in immediate mode. it provides the handle of the channel the data to transform has to be read from. (yes, the original says "this options", we love her anyway. πŸ™ˆ)

if the transformation is in immediate mode and this option is absent, the data to transform is expected as the last argument to the transformation.

  • -out channel β€” this options is legal if and only if the transformation is used in immediate mode. it provides the handle of the channel the generated transformation result is 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. these are the immediate and attached operation modes. two modes, two personalities, both slay. ✨

For the attached mode the option -attach is used to associate the transformation with an existing channel. during the execution of the command no transformation is performed β€” instead the channel is changed in such a way, that from then on all data written to or read from it passes through the transformation and is modified by it according to the definition above. it's like a glow-up for your channel, permanent edition. πŸ’–

This attachment can be revoked by executing the command unstack for the chosen channel. this is the only way to do this at the Tcl level. no other route, bestie. that's the one. πŸšͺ

In the second mode, which can be detected by the absence of option -attach, the transformation immediately takes data from either its commandline or a channel, transforms it, and returns the result either as result of the command, or writes it into a channel. the mode is named after the immediate nature of its execution. main character energy: does the thing right now, no waiting. πŸ”₯

Where the data is taken from, and delivered to, is governed by the presence and absence of the options -in and -out. it should be noted that this ability to immediately read from and/or write to a channel is an historic artifact which was introduced at the beginning of Trf's life when Tcl version 7.6 was current, as this and earlier versions have trouble to deal with \0 characters embedded into either input or output. so yeah, it's giving legacy, she's been here a while. πŸ‘‘

⚠️ heads up bestie: that immediate read/write-to-a-channel thing is old old. Tcl 7.6 and earlier couldn't handle \0 characters in input or output. it's history, not a glow-up.

🌈 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!! 🫢 this was the Trf transformer commands manual, version 2.1.3, and the page is bin(3trf). mwah, go encode something cute. πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from