Hexdump
Dominic Steinitz
dominic.steinitz at blueyonder.co.uk
Sat Mar 18 05:48:40 EST 2006
All,
I finally got around to putting a "hexdump" function into a module. Any
suggestions as to where it should live in the hierarchy?
Dominic.
module Hex(
ppHex
) where
import Data.List
import Codec.Utils
import Numeric
import Text.PrettyPrint
split :: Int -> [a] -> [[a]]
split n xs = unfoldr (g n) xs
g :: Int -> [a] -> Maybe ([a],[a])
g n [] = Nothing
g n y = Just (splitAt n y)
sh x | x < 16 = '0':(showHex x "")
| otherwise = showHex x ""
type OctetsPerLine = Int
ppHex :: OctetsPerLine -> [Octet] -> Doc
ppHex n =
vcat .
map hcat .
map (intersperse colon) .
map (map (text . sh)) .
split n
More information about the Libraries
mailing list