?
This document uses PHP Chinese website manual Release
import "encoding/ascii85"
概述
索引
軟件包 ascii85 實(shí)現(xiàn)了 btoa 工具和 Adobe 的 PostScript 和 PDF 文檔格式中使用的 ascii85 數(shù)據(jù)編碼。
func Decode(dst, src []byte, flush bool) (ndst, nsrc int, err error)
func Encode(dst, src []byte) int
func MaxEncodedLen(n int) int
func NewDecoder(r io.Reader) io.Reader
func NewEncoder(w io.Writer) io.WriteCloser
type CorruptInputError
func (e CorruptInputError) Error() string
ascii85.go
func Decode(dst, src []byte, flush bool) (ndst, nsrc int, err error)
解碼將 src 解碼為 dst,返回寫入 dst 的字節(jié)數(shù)和從 src 消耗的數(shù)字。如果 src 包含無(wú)效的 ascii85 數(shù)據(jù), Decode 將返回成功寫入的字節(jié)數(shù)和一個(gè) CorruptInputError。解碼會(huì)忽略 src 中的空格和控制字符。通常,ascii85 編碼的數(shù)據(jù)被封裝在 <? 和 ?> 符號(hào)中。解碼期望這些被調(diào)用者剝離。
如果 flush 為 true,則 Decode 假定 src 表示輸入流的結(jié)束并完全處理,而不是等待另一個(gè) 32 位塊的完成。
NewDecoder 圍繞 Decode 包裝一個(gè) io.Reader 接口。
func Encode(dst, src []byte) int
將編碼的 src 編碼為至多 dst 的 MaxEncodedLen(len(src))
字節(jié),返回寫入的實(shí)際字節(jié)數(shù)。
編碼處理4字節(jié)塊,對(duì)最后一個(gè)片段使用特殊編碼,所以 Encode 不適用于大數(shù)據(jù)流的各個(gè)塊。改用 NewEncoder()。
通常,ascii85 編碼的數(shù)據(jù)被封裝在 <? 和 ?> 符號(hào)中。編碼不會(huì)添加這些。
func MaxEncodedLen(n int) int
MaxEncodedLen 返回 n 個(gè)源字節(jié)的最大編碼長(zhǎng)度。
func NewDecoder(r io.Reader) io.Reader
NewDecoder 構(gòu)造一個(gè)新的 ascii85 流解碼器。
func NewEncoder(w io.Writer) io.WriteCloser
NewEncoder 返回一個(gè)新的 ascii85 流編碼器。寫入返回的作者的數(shù)據(jù)將被編碼,然后寫入 w。Ascii85 編碼在 32 位塊中運(yùn)行;寫完后,調(diào)用者必須關(guān)閉返回的編碼器以刷新任何尾部分塊。
type CorruptInputError int64
func (e CorruptInputError) Error() string