Go encoding/ascii85: encode binary data as used in PostScript and PDF
Answer: The ascii85 package implements the encoding used by the btoa tool and by Adobe PostScript and PDF document formats.
Encode and decode
Decode returns a CorruptInputError plus the number of bytes successfully written when src contains invalid ascii85 data.
Often, ascii85-encoded data is wrapped in <~ and ~> symbols.
Decode expects these wrappers to have been stripped by the caller. Encode does not add these.
Decode ignores space and control characters in src.
If flush is true, Decode assumes src is the end of the input stream and processes it completely rather than wait for another 32-bit block.
Stream helpers
The encoding handles 4-byte chunks and uses a special encoding for the last fragment, so Encode is not appropriate for individual blocks of a large data stream.
Use NewEncoder instead.
MaxEncodedLen returns the maximum length of an encoding of n source bytes.
NewDecoder constructs a new ascii85 stream decoder.
NewEncoder returns a stream encoder. Bytes written to that writer are encoded, then written to w.
See also
Claims
- id: C1 claim: Decode skips spaces and control characters in its input. source: S1 evidence: "Decode ignores space and control characters in src."
- id: C2 claim: Callers often wrap ascii85 data in <~ and ~> markers. source: S1 evidence: "Often, ascii85-encoded data is wrapped in <~ and ~> symbols."
- id: C3 claim: The source package comment names the btoa tool and Adobe PostScript and PDF formats. source: S2 evidence: "as used in the btoa tool and Adobe's PostScript and PDF document formats."
Sources
- [S1] encoding/ascii85. The Go Authors. https://pkg.go.dev/encoding/ascii85 . License: BSD-3-Clause. Accessed 2026-11-26.
- [S2] ascii85.go (source). The Go Authors. https://go.dev/src/encoding/ascii85/ascii85.go . License: BSD-3-Clause. Accessed 2026-11-26.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: The Go Authors, encoding/ascii85; The Go Authors, ascii85.go (source). BSD-3-Clause (https://go.dev/LICENSE). Copyright The Go Authors. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: The Go Authors, encoding/ascii85; The Go Authors, ascii85.go (source). BSD-3-Clause (https://go.dev/LICENSE). Copyright The Go Authors.
Cite this
iinventedlight. 2026. "Go encoding/ascii85: encode binary data as used in PostScript and PDF." iinventedlight Library, iil:note:eyva0ex8, version of 2026-11-26. https://iinventedlight.com/library/notes/go-encoding-ascii85/. License: CC-BY-4.0.
@misc{iil_note_eyva0ex8,
author = {{iinventedlight}},
title = {{Go encoding/ascii85: encode binary data as used in PostScript and PDF}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-26},
url = {https://iinventedlight.com/library/notes/go-encoding-ascii85/},
note = {Permanent ID iil:note:eyva0ex8. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
Extra files beside this note
These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.
- go-encoding-ascii85.schema.json (schema; CC-BY-4.0)
- go-encoding-ascii85.table.json (table; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/go-encoding-ascii85.md.