github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/encoding/ascii85/ascii85.go (about)

     1  // Copyright 2009 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // Package ascii85はbtoaツールやAdobeのPostScriptおよびPDFドキュメント形式で使用されているascii85データエンコーディングを実装しています。
     6  package ascii85
     7  
     8  import (
     9  	"github.com/shogo82148/std/io"
    10  )
    11  
    12  // Encode encodes src into at most [MaxEncodedLen](len(src))
    13  // bytes of dst, returning the actual number of bytes written.
    14  //
    15  // The encoding handles 4-byte chunks, using a special encoding
    16  // for the last fragment, so Encode is not appropriate for use on
    17  // individual blocks of a large data stream. Use [NewEncoder] instead.
    18  //
    19  // しばしば、ascii85でエンコードされたデータは<~と~>の記号で囲まれていますが、Encodeはこれを追加しません。
    20  func Encode(dst, src []byte) int
    21  
    22  // MaxEncodedLenは、n個のソースバイトのエンコーディングの最大長を返します。
    23  func MaxEncodedLen(n int) int
    24  
    25  // NewEncoderは新しいascii85ストリームエンコーダーを返します。返されたライターに書き込まれたデータはエンコードされ、wに書き込まれます。Ascii85エンコーディングは32ビットのブロックで動作します。書き込みが終了したら、呼び出し元は残りの部分ブロックをフラッシュするために返されたエンコーダーを閉じる必要があります。
    26  func NewEncoder(w io.Writer) io.WriteCloser
    27  
    28  type CorruptInputError int64
    29  
    30  func (e CorruptInputError) Error() string
    31  
    32  // Decode decodes src into dst, returning both the number
    33  // of bytes written to dst and the number consumed from src.
    34  // If src contains invalid ascii85 data, Decode will return the
    35  // number of bytes successfully written and a [CorruptInputError].
    36  // Decode ignores space and control characters in src.
    37  // Often, ascii85-encoded data is wrapped in <~ and ~> symbols.
    38  // Decode expects these to have been stripped by the caller.
    39  //
    40  // flushがtrueの場合、Decodeはsrcが入力ストリームの終わりを表し、別の32ビットブロックの完了を待つのではなく、完全に処理すると想定します。
    41  //
    42  // [NewDecoder] wraps an [io.Reader] interface around Decode.
    43  func Decode(dst, src []byte, flush bool) (ndst, nsrc int, err error)
    44  
    45  // NewDecoder は新しい ascii85 ストリームデコーダを構築します。
    46  func NewDecoder(r io.Reader) io.Reader