Codec.Binary.PythonString

dataenc-0.13.0.4: Data encoding library

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

- encode :: [Word8] -> String
- decode :: String -> Maybe [Word8]
- decode' :: String -> [Maybe Word8]
- chop :: Int -> String -> [String]
- unchop :: [String] -> String

# Documentation

encode :: [Word8] -> String

Encode data.

decode :: String -> Maybe [Word8]

Decode data (strict).

decode' :: String -> [Maybe Word8]

chop

Arguments

:: Int | length of individual lines (values `< 1` are ignored)
-> String |
-> [String] |

Chop up a string in parts.

unchop :: [String] -> String

Concatenate the list of strings into one long string.