Codec.Binary.Xx

sandi-0.5: Data encoding library

Copyright | (c) 2012 Magnus Therning
License | BSD3
Safe Haskell | None
Language | Haskell2010

Codec.Binary.Xx

Description

Xxencoding is obsolete but still included for completeness. Further information on the encoding can be found at http://en.wikipedia.org/wiki/Xxencode. It should be noted that this implementation performs no padding.

This encoding is very similar to uuencoding, therefore further information regarding the functions can be found in the documentation of Codec.Binary.Uu.

Synopsis

- xxEncodePart :: ByteString -> (ByteString, ByteString)
- xxEncodeFinal :: ByteString -> Maybe ByteString
- xxDecodePart :: ByteString -> Either (ByteString, ByteString) (ByteString, ByteString)
- xxDecodeFinal :: ByteString -> Maybe ByteString
- encode :: ByteString -> ByteString
- decode :: ByteString -> Either (ByteString, ByteString) ByteString

# Documentation

xxEncodePart :: ByteString -> (ByteString, ByteString) #

Encoding function.

    >>> xxEncodePart $ Data.ByteString.Char8.pack "foo"
    ("Naxj","")
    >>> xxEncodePart $ Data.ByteString.Char8.pack "foob"
    ("Naxj","b")

xxEncodeFinal :: ByteString -> Maybe ByteString #

Encoding function for the final block.

    >>> xxEncodeFinal $ Data.ByteString.Char8.pack "r"
    Just "QU"
    >>> xxEncodeFinal $ Data.ByteString.Char8.pack "foo"
    Nothing

xxDecodePart :: ByteString -> Either (ByteString, ByteString) (ByteString, ByteString) #

Decoding function.

    >>> xxDecodePart $ Data.ByteString.Char8.pack "Naxj"
    Right ("foo","")
    >>> xxDecodePart $ Data.ByteString.Char8.pack "NaxjMa3"
    Right ("foo","Ma3")

    >>> xxDecodePart $ Data.ByteString.Char8.pack "Na j"
    Left ("","Na J")

xxDecodeFinal :: ByteString -> Maybe ByteString #

Decoding function for the final block.

    >>> xxDecodeFinal $ Data.ByteString.Char8.pack "Naw"
    Just "fo"
    >>> xxDecodeFinal $ Data.ByteString.Char8.pack ""
    Just ""
    >>> xxDecodeFinal $ Data.ByteString.Char8.pack "Na "
    Nothing

    >>> xxDecodeFinal $ encode $ Data.ByteString.Char8.pack "foo"
    Nothing

encode :: ByteString -> ByteString #

decode :: ByteString -> Either (ByteString, ByteString) ByteString #