base64(3trf)
π base64(3trf) β the glow-up guide π
okay bestie, sit down, hydrate, and let me tell you about base64 from the Trf transformer squad. no cap, this one's a classic. β¨
πΈ NAME πΈ
base64 β encoding "base64" π
π SYNOPSIS π
package require Tcl ?8.2?
package require Trf ?2.1.3?
base64 ?options...? ?data?
like yes she requires Tcl ?8.2? and Trf ?2.1.3? first, she's not low-maintenance, she's worth it π«Ά
β¨ DESCRIPTION β¨
so base64 is one of the several data encodings that the trf package serves up. if you want the whole ensemble, go look at trf-intro for an overview of the entire package. she's part of a friend group, she's not doing this alone. π
what does she actually do? this encoding takes every block of three bytes and turns it into a block of four bytes, and every one of those output bytes is printable β meaning 7bit ASCII. which also means the result is valid UTF-8 too. she's giving range. she's giving versatility. π
the command uses essentially the same algorithm as uuencode does β the only difference is a different mapping from 6-bit fragments to printable bytes. same dance, different choreography. π¦
base64 ?options...? ?data?
π the options (the whole menu, don't skip a single one)
-mode encode|decodeβ this one is mandatory, bestie. she is always understood by the encoding. for immediate mode, the argument value tells you which operation to use. for an attached encoding, it specifies the operation to use for writing β and reading will automatically use the reverse operation, because she's efficient like that. (see the IMMEDIATE versus ATTACHED section below for what those two terms even mean, iykyk.) also, beyond the argument values listed above, all unique abbreviations are recognized too.encodeconverts from arbitrary (most likely binary) data into the described representation, anddecodedoes the reverse. periodt. π-attach channelβ the presence or absence of this option is literally the main character here, because it determines the main operation mode of the transformation. if it's present, the transformation gets stacked onto the channel whose handle you gave to the option and runs in attached mode. more on that in the IMMEDIATE versus ATTACHED section. if the option is absent, the transformation is used in immediate mode and the options listed below get recognized. again β more on that below. π-in channelβ this option is legal if and only if the transformation is used in immediate mode. it provides 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. choose your path. π¦-out channelβ same energy, also legal if and only if the transformation is used in immediate mode. it provides 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, then the generated data is returned as the result of the command itself. no channel, no problem, she hands it to you directly. π«Ά
π NOTES π
- the encoding is equivalent to PGP's ASCII armor, and was also accepted as one of the MIME encodings for encapsulation of binary data. see RFC 2045 (http://www.rfc-editor.org/rfc/rfc2045.txt) for the details and the specification of this encoding. she's got receipts. πβ¨
- the encoding buffers 2 bytes. tiny buffer, big dreams. π
π₯ IMMEDIATE VERSUS ATTACHED π₯
the transformation distinguishes between two main ways of using it. these are the immediate and attached operation modes. let's break it down because this is the part everyone skips and then cries about. π
π attached mode
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 itself is changed in such a way that, from then on, all data written to or read from it passes through the transformation and gets modified by it according to the definition above. it's giving β¨permanent residencyβ¨.
this attachment can be revoked by executing the command unstack for the chosen channel. and heads up: this is the only way to do this at the Tcl level. no shortcuts, bestie.
π¦ immediate mode
in the second mode β which you can detect 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 the result of the command, or writes it into a channel. the mode is named after the immediate nature of its execution. she's impulsive. she's decisive. she ate. π
where the data is taken from, and delivered to, is governed by the presence and absence of the options -in and -out. and ngl, 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, back when Tcl version 7.6 was current β because this and earlier versions have trouble dealing with \0 characters embedded into either input or output. so yeah, it's a legacy vibe. respect your elders. π
π SEE ALSO π
ascii85, base64, bin, hex, oct, otp_words, quoted-printable, trf-intro, uuencode
the whole group chat. go say hi. π«Ά
β KEYWORDS β
ascii armor, base64, encoding, mime, pgp, rfc 2045, uuencode
π COPYRIGHT π
Copyright (c) 1996-2003, Andreas Kupries <andreas_kupries@users.sourceforge.net>
and that's the whole page, bestie!! π this little love letter to base64 came to you from the Trf transformer commands, version 2.1.3, page base64(3trf). go forth and encode responsibly. mwah. πβ¨π¦
π¦ where this page comes from
- debian bookworm: tcl-trf-doc 2.1.4-dfsg3-2.1
- debian trixie: tcl-trf-doc 2.1.4-dfsg3-8
- ubuntu jammy: tcl-trf-doc 2.1.4-dfsg3-2.1build1
- ubuntu noble: tcl-trf-doc 2.1.4-dfsg3-3
- ubuntu questing: tcl-trf-doc 2.1.4-dfsg3-8
- ubuntu resolute: tcl-trf-doc 2.1.4-dfsg3-8build1
- ubuntu stonking: tcl-trf-doc 2.1.4-dfsg3-9build1
- Copyright (c) 1996-2003, Andreas Kupries <andreas_kupries@users.sourceforge.net>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms