Copyright | (c) 2009 Magnus Therning |
---|---|
License | BSD3 |
Safe Haskell | Safe-Inferred |
Language | Haskell98 |
Codec.Binary.PythonString
Description
Implementation of python escaping.
This implementation encodes non-printable characters (0x00-0x1f, 0x7f-0xff) to hex-value characters ('xhh') while leaving printable characters as such:
> encode [0, 10, 13, 110] "\\x00\\x0A\\x0Dn" > putStrLn $ encode [0, 10, 13, 110] \x00\x0A\x0Dn
It also properly handles escaping of a few characters that require it:
> encode [34, 39, 92] "\\\"\\'\\\\" putStrLn $ encode [34, 39, 92] \"\'\\
Further documentation and information can be found at http://www.haskell.org/haskellwiki/Library/Data_encoding.
Synopsis
- data EncIncData
- data EncIncRes i
- = EPart i (EncIncData -> EncIncRes i)
- | EFinal i
- encodeInc :: EncIncData -> EncIncRes String
- encode :: [Word8] -> String
- data DecIncData i
- data DecIncRes i
- = DPart [Word8] (DecIncData i -> DecIncRes i)
- | DFinal [Word8] i
- | DFail [Word8] i
- decodeInc :: DecIncData String -> DecIncRes String
- decode :: String -> Maybe [Word8]
- chop :: Int -> String -> [String]
- unchop :: [String] -> String
Documentation
data EncIncData Source #
Data type for the incremental encoding functions.
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 |
encodeInc :: EncIncData -> EncIncRes String Source #
Incremental encoder function.
data DecIncData i Source #
Data type for the incremental decoding functions.
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 |
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 String Source #
Incremental decoder function.
Arguments
:: Int | length of individual lines (values |
-> String | |
-> [String] |
Chop up a string in parts.