Standard library / encoding/ascii85

encoding/ascii85.Encode()

Encode a complete byte slice into ASCII85. Allocate MaxEncodedLen bytes; use only the returned prefix. Delimiters are not included. Expected stdout: '7rJ\n'.

Formal Syntax & Structure

go syntaxgo
func Encode(dst, src []byte) int

Parameters & Attributes

NameTypeDescription
dst[]byteDestination byte slice; provide enough capacity for the operation or use an append API.
src[]byteInput bytes in the format expected by the operation.

Return Value

int

Byte count or length bound, as specified by the operation.

Working Example

Example Snippetgo
package main
import (  "encoding/ascii85"  "fmt")
func must(e error) {  if e != nil {    panic(e)  }}
func main() {  src := []byte("Go")  dst := make([]byte, ascii85.MaxEncodedLen(len(src)))  n := ascii85.Encode(dst, src)  fmt.Println(string(dst[:n]))}
Go Reference