dataenc-0.14.0.2: Data encoding library

Codec.Binary.Uu

Description

Uuencoding is notoriously badly specified. This implementation is compatible with the GNU Sharutils (http://www.gnu.org/software/sharutils/).

Further documentation and information can be found at http://www.haskell.org/haskellwiki/Library/Data_encoding.

Synopsis

Documentation

data EncIncData Source

Data type for the incremental encoding functions.

Constructors

EChunk [Word8]

a chunk of data to be encoded

EDone

the signal to the encoder that the stream of data is ending

data EncIncRes i Source

Data type for the result of calling the incremental encoding functions.

Constructors

EPart i (EncIncData -> EncIncRes i)

a partial result together with the continuation to use for further encoding

EFinal i

the final result of encoding (the response to EDone)

encodeInc :: EncIncData -> EncIncRes StringSource

Incremental encoder function.

encode :: [Word8] -> StringSource

Encode data.

data DecIncData i Source

Data type for the incremental decoding functions.

Constructors

DChunk i

a chunk of data to be decoded

DDone

the signal to the decoder that the stream of data is ending

data DecIncRes i Source

Data type for the result of calling the incremental encoding functions.

Constructors

DPart [Word8] (DecIncData i -> DecIncRes i)

a partial result together with the continuation to user for further decoding

DFinal [Word8] i

the final result of decoding (the response to DDone)

DFail [Word8] i

a partial result for a failed decoding, together with the remainder of the data passed in so far

decodeInc :: DecIncData String -> DecIncRes StringSource

Incremental decoder function.

decode :: String -> Maybe [Word8]Source

Decode data.

chopSource

Arguments

:: Int

length (value should be in the range [5..85])

-> String 
-> [String] 

Chop up a string in parts. Each string in the resulting list is prepended with the length according to the uuencode "specificiation".

Notes:

  • The length of the strings in the result will be (n -1) div 4 * 4 + 1. The -1 comes from the need to prepend the length (which explains the final +1). Keeping it to a multiple of 4 means that strings returned from encode can be chopped without requiring any changes.
  • The length of lines in GNU's sharutils is 61.

unchop :: [String] -> StringSource

Concatenate the strings into one long string. Each string is assumed to be prepended with the length according to the uuencode specification.