MissingH-1.4.1.0: Large utility library

Copyright | Copyright (C) 2004-2011 John Goerzen
License | BSD3
Maintainer | John Goerzen <jgoerzen@complete.org>
Stability | provisional
Portability | portable to platforms with rawSystem
Safe Haskell | Safe
Language | Haskell98

Data.Bits.Utils

Description

Bit-related utilities

Written by John Goerzen, jgoerzen@complete.org

Synopsis

- getBytes :: (Integral a, Bounded a, Bits a) => a -> [a]
- fromBytes :: (Bits a, Num a) => [a] -> a
- c2w8 :: Char -> Word8
- s2w8 :: String -> [Word8]
- w82c :: Word8 -> Char
- w82s :: [Word8] -> String

# Documentation

getBytes :: (Integral a, Bounded a, Bits a) => a -> [a] Source #

Returns a list representing the bytes that comprise a data type.

Example:

    getBytes (0x12345678::Int) -> [0x12, 0x34, 0x56, 0x78]

fromBytes :: (Bits a, Num a) => [a] -> a Source #

The opposite of `getBytes`, this function builds a number based on its component bytes.

Results are undefined if any components of the input list are > 0xff!

c2w8 :: Char -> Word8 Source #

Converts a Char to a Word8.

s2w8 :: String -> [Word8] Source #

Converts a String to a [Word8].

w82c :: Word8 -> Char Source #

Converts a Word8 to a Char.

w82s :: [Word8] -> String Source #

Converts a [Word8] to a String.