← All notes

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

Sources

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

Permanent ID: iil:note:eyva0ex8

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.},
}

Markdown

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.

All artifact files (JSON index)

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.