sandi-0.4.3: Data encoding library
Copyright(c) 2012 Magnus Therning
LicenseBSD3
Safe HaskellNone
LanguageHaskell2010

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

Documentation

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

Encoding function.

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

xxEncodeFinal :: ByteString -> Maybe ByteString Source #

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) Source #

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 Source #

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