codec
Visionary Software Solutions Codec: the contract of a binary-to-text codec, whose text is typed by its symbols
The contract of a binary-to-text codec: bits in, text out, and back. The text is typed by the symbols it holds, so one codec's text is never another's. Base16, base32, base45 and base64 implement it.
Key Concepts
Codec contract
Role. Codec<S> encodes bits as Encoded<S> and decodes that back to bits. It takes any software.visionary.wheeler.Bits, whatever holds them. read takes characters to encoded data, and its toString() writes them. A codec is also a SerializationStrategy<Encoded<S>>: deserialize encodes a byte array and serialize decodes to one.
Symbols and alphabets
Role. A Symbol is one element of a codec's text, written as a glyph of software.visionary.cuneiform.graphic. It answers the character it is written as, and a constant of the alphabet it belongs to, which answers for the whole of it. An Alphabet is an enum of symbols: each constant picks its glyph, its place in the enum is its value, and any constant reads a glyph as the constant that writes it. Both are open, so a codec may seal the symbols its own text holds.
Encoded data
Role. Encoded<S> is an immutable sequence of the symbols S. EncodedFactory makes it over a source of symbols: the data holds the source, and walks it anew for each walk, comparison and toString().
Views
Role. encode, decode and read answer with views of what they were given. A view computes as it is walked and holds nothing per bit or per symbol, so only its source bounds its length. The byte-array methods hold octets packed, a byte each, and read a bit by a position a long counts. Packed octets are software.visionary.wheeler.tets.Segmented and hand over an octet at a time.
Conventions
Role. Conventions states once what the codecs do alike, and a codec's implementation mixes it in: an octet is eight bits, a group of bits holds a number most significant bit first, and text is read one graphic character at a time. octets gives any bits as the bytes of their octets: segmented bits are taken a segment at a time, so a whole octet passes without its bits being walked, and other bits are walked.
Claims
Role. Claims states what a codec's specification claims of it: that it writes octets as a text, reads a text as octets, refuses a text, decodes what it encodes, and decodes only the text it writes.
Usage
Write octets as text with any codec, and read them back
import software.visionary.cuneiform.codec.Codec;
import software.visionary.cuneiform.codec.Symbol;
class Wire {
static <S extends Symbol<?>> String written(final Codec<S> codec, final byte[] octets) {
return codec.deserialize(octets).toString();
}
static <S extends Symbol<?>> byte[] octets(final Codec<S> codec, final String written) {
return codec.serialize(codec.read(written));
}
}
Dependencies
software.visionary.cuneiform:graphic:2026.10.13at Compilesoftware.visionary.serialization:api:2026.10.13at Compilesoftware.visionary.wheeler:tets:2026.10.13at Compilesoftware.visionary:factory:2026.10.13at Compilesoftware.visionary.contrax:processor:2026.10.13at Processorsoftware.visionary:spex-closure:2026.10.13at Testing
Caveats
- The bits walked from
decodebefore a refusal have already been handed over. Useserializewhere a text must be accepted whole or not at all. - A byte array and a
Stringeach hold at most 231−1 elements, soserialize,deserializeandtoString()stop there.encodeanddecodedo not.
Views
Drawn from the release. A link in a view opens its source at the release tag.