ascii85(n)
πΈ ascii85(n) β Text encoding & decoding binary data πΈ
ok so bestie, you know how sometimes you have β¨binary dataβ¨ and you need to shove it through a text-only tube like email or PostScript or whatever? yeah. that's this. this is the ascii85 page, from the tcllib crew, and it's lowkey iconic π
π NAME π
ascii85 β ascii85-encode/decode binary data
β¨ SYNOPSIS β¨
package require Tcl 8.5 9
package require ascii85 ?1.1?
::ascii85::encode ?-maxlen maxlen? ?-wrapchar wrapchar? string
::ascii85::decode string
π¦ DESCRIPTION π¦
So this package hands you two procedures: one to take binary data and turn it into ascii85, and one to take it right back. round trip, bestie π«Ά
π ::ascii85::encode ?-maxlen maxlen? ?-wrapchar wrapchar? string
This one ascii85-encodes the binary string you hand it and gives you back the encoded result. it drops the character wrapchar in every maxlen characters of output, like a little breather. wrapchar defaults to newline. maxlen defaults to 76. so yes, it's already wrapped for you by default, no need to ask π
Note well: If your string is not simple ascii you should fix the string encoding before doing ascii85 encoding. See the examples. like, do NOT skip this, bestie, I am begging π
Also, the command will throw an error for negative values of maxlen, or if maxlen is not an integer number. so don't try it. it will not be cute π
π ::ascii85::decode string
Ascii85 decodes the given string and returns the binary data. the decoder ignores whitespace in the string, as well as tabs and newlines. it's very chill about that, very unbothered, main character energy β¨
π EXAMPLES π
watch this:
% ascii85::encode "Hello, world"
87cURD_*#TDfTZ)
and a bigger one:
% ascii85::encode [string repeat xyz 24]
G^4U[H$X^\H?a^]G^4U[H$X^\H?a^]G^4U[H$X^\H?a^]G^4U[H$X^\H?a^]G^4U[H$X^\H?a^]G
^4U[H$X^\H?a^]
see how it wrapped? now kill the wrapchar and it's one long vibe:
% ascii85::encode -wrapchar "" [string repeat xyz 24]
G^4U[H$X^\H?a^]G^4U[H$X^\H?a^]G^4U[H$X^\H?a^]G^4U[H$X^\H?a^]G^4U[H$X^\H?a^]G^4U[H$X^\H?a^]
and here's the one that matters, the encoding reminder:
# NOTE: ascii85 encodes BINARY strings.
% set chemical [encoding convertto utf-8 "C\u2088H\u2081\u2080N\u2084O\u2082"]
% set encoded [ascii85::encode $chemical]
6fN]R8E,5Pidu\UiduhZidua
% set caffeine [encoding convertfrom utf-8 [ascii85::decode $encoded]]
like, look at that. converted to utf-8 FIRST, then encoded. that's the whole point of the note. slay π
π REFERENCES π
- [1] http://en.wikipedia.org/wiki/Ascii85
- [2] Postscript Language Reference Manual, 3rd Edition, page 131. http://www.adobe.com/devnet/postscript/pdfs/PLRM.pdf
π BUGS, IDEAS, FEEDBACK π
ngl, this document, and the package it describes, will undoubtedly contain bugs and other problems. it's giving "we're all just doing our best". Please report such in the category base64 of the Tcllib Trackers [http://core.tcl.tk/tcllib/reportlist]. (yes, base64, that's what it says, I don't make the rules π§) Please also report any ideas for enhancements you may have for either package and/or documentation.
When proposing code changes, please provide unified diffs, i.e the output of diff -u.
Note further that attachments are strongly preferred over inlined patches. Attachments can be made by going to the Edit form of the ticket immediately after its creation, and then using the left-most button in the secondary navigation bar. do it the easy way, bestie, don't paste a wall of patch into the ticket, we're all tired π
π₯ KEYWORDS π₯
ascii85, encoding
π CATEGORY π
Text processing
π COPYRIGHT π
Copyright (c) 2010, Emiliano GavilΓ‘n
ok that's the whole page, and that's on periodt β¨ this is tcllib version 1.1.1, and it's the ascii85(n) manual page you've been reading this entire time β yes, we came full circle, that's the vibe check passing. go encode something, bestie, and remember: fix your string encoding first πΈππ¦
π¦ where this page comes from
- fedora 43: tcllib 2.0-3.fc43 Β· TCL
- fedora 44: tcllib 2.0-4.fc44 Β· TCL
- nixos 26.05: tcllib 2.0
- nixpkgs unstable: tcllib 2.0
- Copyright (c) 2010, Emiliano GavilΓ‘n
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms