Copyright | (c) 2011 MailRank Inc. |
---|---|
License | BSD |
Maintainer | Herbert Valerio Riedel <hvr@gnu.org>, Mikhail Glushenkov <mikhail.glushenkov@gmail.com>, Emily Pillmore <emilypi@cohomolo.gy> |
Stability | stable |
Portability | non-portable |
Safe Haskell | Trustworthy |
Language | Haskell2010 |
RFC 4648-compliant Base16 (Hexadecimal) encoding for ByteString
values.
For a complete Base16 encoding specification, please see RFC-4648 section 8.
Synopsis
- encode :: ByteString -> ByteString
- decode :: ByteString -> Either String ByteString
- decodeLenient :: ByteString -> ByteString
Documentation
encode :: ByteString -> ByteString Source #
Encode a ByteString
value in base16 (i.e. hexadecimal).
Encoded values will always have a length that is a multiple of 2.
Examples:
encode "foo" == "666f6f"
decode :: ByteString -> Either String ByteString Source #
Decode a base16-encoded ByteString
value.
If errors are encountered during the decoding process,
then an error message and character offset will be returned in
the Left
clause of the coproduct.
Examples:
decode "666f6f" == Right "foo" decode "66quux" == Left "invalid character at offset: 2" decode "666quux" == Left "invalid character at offset: 3"
Since: 1.0.0.0
decodeLenient :: ByteString -> ByteString Source #
Decode a Base16-encoded ByteString
value leniently, using a
strategy that never fails.
N.B.: this is not RFC 4648-compliant
Examples:
decodeLenient "666f6f" == "foo" decodeLenient "66quuxx" == "f" decodeLenient "666quux" == "f" decodeLenient "666fquu" -- "fo"
Since: 1.0.0.0