base85

package
v1.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 22, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package base85 implements base85 encoding and decoding with streaming support. It provides base85 encoding using Go's standard encoding/ascii85 package, which implements the ASCII85 encoding as specified in Adobe's PostScript and PDF specifications.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewStreamDecoder

func NewStreamDecoder(r io.Reader) io.Reader

NewStreamDecoder creates a new streaming base85 decoder that reads encoded data from the provided io.Reader. The decoder uses the standard ASCII85 alphabet.

func NewStreamEncoder

func NewStreamEncoder(w io.Writer) io.WriteCloser

NewStreamEncoder creates a new streaming base85 encoder that writes encoded data to the provided io.Writer. The encoder uses the standard ASCII85 alphabet.

Types

type CorruptInputError

type CorruptInputError int64

CorruptInputError represents an error when corrupted or invalid base85 data is detected during decoding. This error occurs when an invalid character is found in the input or when the input data is malformed.

func (CorruptInputError) Error

func (e CorruptInputError) Error() string

Error returns a formatted error message describing the corrupted input. The message includes the position where corruption was detected.

type StdDecoder

type StdDecoder struct {
	Error error // Error field for storing decoding errors
}

StdDecoder represents a base85 decoder for standard decoding operations. It implements base85 decoding using Go's standard encoding/ascii85 package, providing efficient decoding of ASCII85 strings back to binary data.

func NewStdDecoder

func NewStdDecoder() *StdDecoder

NewStdDecoder creates a new base85 decoder using the standard ASCII85 alphabet.

func (*StdDecoder) Decode

func (d *StdDecoder) Decode(src []byte) (dst []byte, err error)

Decode decodes the given ASCII85-encoded byte slice back to binary data. Uses Go's standard encoding/ascii85 package for reliable and efficient decoding. Handles special cases like "z" representing 4 zero bytes and incomplete groups.

type StdEncoder

type StdEncoder struct {
	Error error // Error field for storing encoding errors
}

StdEncoder represents a base85 encoder for standard encoding operations. It implements base85 encoding using Go's standard encoding/ascii85 package, providing efficient encoding of binary data to ASCII85 strings.

func NewStdEncoder

func NewStdEncoder() *StdEncoder

NewStdEncoder creates a new base85 encoder using the standard ASCII85 alphabet.

func (*StdEncoder) Encode

func (e *StdEncoder) Encode(src []byte) (dst []byte)

Encode encodes the given byte slice using ASCII85 encoding. Uses Go's standard encoding/ascii85 package for reliable and efficient encoding.

type StreamDecoder

type StreamDecoder struct {
	Error error // Error field for storing decoding errors
	// contains filtered or unexported fields
}

StreamDecoder represents a streaming base85 decoder that implements io.Reader. It provides efficient decoding for large data streams by processing data in chunks and maintaining an internal buffer for partial reads.

func (*StreamDecoder) Read

func (d *StreamDecoder) Read(p []byte) (n int, err error)

Read implements the io.Reader interface for streaming base85 decoding. Reads and decodes ASCII85 data from the underlying reader in chunks. Maintains an internal buffer to handle partial reads efficiently.

type StreamEncoder

type StreamEncoder struct {
	Error error // Error field for storing encoding errors
	// contains filtered or unexported fields
}

StreamEncoder represents a streaming base85 encoder that implements io.WriteCloser. It provides efficient encoding for large data streams by processing data in chunks and writing encoded output immediately.

func (*StreamEncoder) Close

func (e *StreamEncoder) Close() error

Close implements the io.WriteCloser interface for streaming base85 encoding. Encodes any remaining buffered bytes from the last Write call. This is the only place where we handle cross-Write state.

func (*StreamEncoder) Write

func (e *StreamEncoder) Write(p []byte) (n int, err error)

Write implements the io.Writer interface for streaming base85 encoding. Processes data in chunks while maintaining minimal state for cross-Write calls. This is true streaming - processes data immediately without accumulating large buffers.

Source Files

  • base85.go
  • errors.go

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL