Copyright | (c) Matt Morrow 2008 |
---|---|
License | BSD3 |
Maintainer | Matt Morrow <mjm2002@gmail.com> |
Stability | provisional |
Portability | portable |
Safe Haskell | None |
Language | Haskell98 |
Codec.Binary.UTF8.Light
Description
Lightweight UTF8 handling.
Synopsis
- class UTF8 a where
- lenUTF8 :: Word8 -> Int
- lenUTF16 :: Word16 -> Int
- countUTF8 :: ByteString -> [Int]
- decodeUTF8 :: ByteString -> [Word32]
- encodeUTF8 :: [Word32] -> ByteString
- encodeUTF8' :: [Word32] -> [[Word8]]
- withUTF8 :: UTF8 a => a -> (ByteString -> b) -> b
- putUTF8 :: UTF8 a => a -> IO ()
- putUTF8Ln :: UTF8 a => a -> IO ()
- hPutUTF8 :: UTF8 a => Handle -> a -> IO ()
- hPutUTF8Ln :: UTF8 a => Handle -> a -> IO ()
- readUTF8File :: UTF8 a => FilePath -> IO a
- writeUTF8File :: UTF8 a => FilePath -> a -> IO ()
- appendUTF8File :: UTF8 a => FilePath -> a -> IO ()
- hGetUTF8Line :: UTF8 a => Handle -> IO a
- hGetUTF8Contents :: UTF8 a => Handle -> IO a
- hGetUTF8 :: UTF8 a => Handle -> Int -> IO a
- hGetUTF8NonBlocking :: UTF8 a => Handle -> Int -> IO a
- c2w :: Char -> Word32
- w2c :: Word32 -> Char
- i2w :: Int -> Word32
- w2i :: Word32 -> Int
- flipUTF8 :: UTF8 a => a -> a
- unflipUTF8 :: UTF8 a => a -> a
- flipTab :: [(Int, Int)]
- unflipTab :: [(Int, Int)]
- showHex :: Int -> String
- toBits :: Word8 -> [Word8]
- fromBits :: [Word8] -> Word8
- data Int8
- data Int16
- data Int32
- data Word
- data Word8
- data Word16
- data Word32
Documentation
Instances:
ByteString
, String
, [Word32]
, [Word]
, [Int32]
, [Int]
decodeUTF8 :: ByteString -> [Word32] Source #
encodeUTF8 :: [Word32] -> ByteString Source #
encodeUTF8' :: [Word32] -> [[Word8]] Source #
Word32s not representing valid UTF8 chars are dropped.
hPutUTF8Ln :: UTF8 a => Handle -> a -> IO () Source #
readUTF8File :: UTF8 a => FilePath -> IO a Source #
writeUTF8File :: UTF8 a => FilePath -> a -> IO () Source #
appendUTF8File :: UTF8 a => FilePath -> a -> IO () Source #
hGetUTF8Line :: UTF8 a => Handle -> IO a Source #
hGetUTF8Contents :: UTF8 a => Handle -> IO a Source #
hGetUTF8 :: UTF8 a => Handle -> Int -> IO a Source #
Be careful that you're sure you're not chopping a UTF8 char in two!
hGetUTF8NonBlocking :: UTF8 a => Handle -> Int -> IO a Source #
Same warning as for hGetUTF8
unflipUTF8 :: UTF8 a => a -> a Source #
ghci> putUTF8Ln $ (unflipUTF8 . flipUTF8) "[?np_bs!]" [?np_bs!]
Instances
Bounded Int8 | |
Enum Int8 | |
Eq Int8 | |
Integral Int8 | |
Num Int8 | |
Ord Int8 | |
Read Int8 | |
Real Int8 | |
Defined in GHC.Int Methods toRational :: Int8 -> Rational | |
Show Int8 | |
Ix Int8 | |
Bits Int8 | |
Defined in GHC.Int Methods complement :: Int8 -> Int8 clearBit :: Int8 -> Int -> Int8 complementBit :: Int8 -> Int -> Int8 testBit :: Int8 -> Int -> Bool bitSizeMaybe :: Int8 -> Maybe Int unsafeShiftL :: Int8 -> Int -> Int8 unsafeShiftR :: Int8 -> Int -> Int8 rotateL :: Int8 -> Int -> Int8 | |
FiniteBits Int8 | |
Defined in GHC.Int Methods finiteBitSize :: Int8 -> Int countLeadingZeros :: Int8 -> Int countTrailingZeros :: Int8 -> Int |
Instances
Bounded Int16 | |
Enum Int16 | |
Eq Int16 | |
Integral Int16 | |
Num Int16 | |
Ord Int16 | |
Read Int16 | |
Real Int16 | |
Defined in GHC.Int Methods toRational :: Int16 -> Rational | |
Show Int16 | |
Ix Int16 | |
Bits Int16 | |
Defined in GHC.Int Methods (.&.) :: Int16 -> Int16 -> Int16 (.|.) :: Int16 -> Int16 -> Int16 xor :: Int16 -> Int16 -> Int16 complement :: Int16 -> Int16 shift :: Int16 -> Int -> Int16 rotate :: Int16 -> Int -> Int16 setBit :: Int16 -> Int -> Int16 clearBit :: Int16 -> Int -> Int16 complementBit :: Int16 -> Int -> Int16 testBit :: Int16 -> Int -> Bool bitSizeMaybe :: Int16 -> Maybe Int shiftL :: Int16 -> Int -> Int16 unsafeShiftL :: Int16 -> Int -> Int16 shiftR :: Int16 -> Int -> Int16 unsafeShiftR :: Int16 -> Int -> Int16 rotateL :: Int16 -> Int -> Int16 | |
FiniteBits Int16 | |
Defined in GHC.Int Methods finiteBitSize :: Int16 -> Int countLeadingZeros :: Int16 -> Int countTrailingZeros :: Int16 -> Int |
Instances
Bounded Int32 | |
Enum Int32 | |
Eq Int32 | |
Integral Int32 | |
Num Int32 | |
Ord Int32 | |
Read Int32 | |
Real Int32 | |
Defined in GHC.Int Methods toRational :: Int32 -> Rational | |
Show Int32 | |
Ix Int32 | |
Bits Int32 | |
Defined in GHC.Int Methods (.&.) :: Int32 -> Int32 -> Int32 (.|.) :: Int32 -> Int32 -> Int32 xor :: Int32 -> Int32 -> Int32 complement :: Int32 -> Int32 shift :: Int32 -> Int -> Int32 rotate :: Int32 -> Int -> Int32 setBit :: Int32 -> Int -> Int32 clearBit :: Int32 -> Int -> Int32 complementBit :: Int32 -> Int -> Int32 testBit :: Int32 -> Int -> Bool bitSizeMaybe :: Int32 -> Maybe Int shiftL :: Int32 -> Int -> Int32 unsafeShiftL :: Int32 -> Int -> Int32 shiftR :: Int32 -> Int -> Int32 unsafeShiftR :: Int32 -> Int -> Int32 rotateL :: Int32 -> Int -> Int32 | |
FiniteBits Int32 | |
Defined in GHC.Int Methods finiteBitSize :: Int32 -> Int countLeadingZeros :: Int32 -> Int countTrailingZeros :: Int32 -> Int | |
UTF8 [Int32] Source # | |
Instances
Bounded Word | |
Enum Word | |
Eq Word | |
Integral Word | |
Num Word | |
Ord Word | |
Read Word | |
Real Word | |
Defined in GHC.Real Methods toRational :: Word -> Rational | |
Show Word | |
Bits Word | |
Defined in Data.Bits Methods complement :: Word -> Word clearBit :: Word -> Int -> Word complementBit :: Word -> Int -> Word testBit :: Word -> Int -> Bool bitSizeMaybe :: Word -> Maybe Int unsafeShiftL :: Word -> Int -> Word unsafeShiftR :: Word -> Int -> Word rotateL :: Word -> Int -> Word | |
FiniteBits Word | |
Defined in Data.Bits Methods finiteBitSize :: Word -> Int countLeadingZeros :: Word -> Int countTrailingZeros :: Word -> Int | |
Generic1 (URec Word :: k -> Type) | |
UTF8 [Word] Source # | |
Functor (URec Word :: Type -> Type) | |
Foldable (URec Word :: Type -> Type) | |
Defined in Data.Foldable Methods fold :: Monoid m => URec Word m -> m foldMap :: Monoid m => (a -> m) -> URec Word a -> m foldr :: (a -> b -> b) -> b -> URec Word a -> b foldr' :: (a -> b -> b) -> b -> URec Word a -> b foldl :: (b -> a -> b) -> b -> URec Word a -> b foldl' :: (b -> a -> b) -> b -> URec Word a -> b foldr1 :: (a -> a -> a) -> URec Word a -> a foldl1 :: (a -> a -> a) -> URec Word a -> a elem :: Eq a => a -> URec Word a -> Bool maximum :: Ord a => URec Word a -> a minimum :: Ord a => URec Word a -> a | |
Traversable (URec Word :: Type -> Type) | |
Eq (URec Word p) | |
Ord (URec Word p) | |
Show (URec Word p) | |
Generic (URec Word p) | |
data URec Word (p :: k) | |
Defined in GHC.Generics | |
type Rep1 (URec Word :: k -> Type) | |
Defined in GHC.Generics type Rep1 (URec Word :: k -> Type) = D1 (MetaData "URec" "GHC.Generics" "base" False) (C1 (MetaCons "UWord" PrefixI True) (S1 (MetaSel (Just "uWord#") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (UWord :: k -> Type))) | |
type Rep (URec Word p) | |
Defined in GHC.Generics type Rep (URec Word p) = D1 (MetaData "URec" "GHC.Generics" "base" False) (C1 (MetaCons "UWord" PrefixI True) (S1 (MetaSel (Just "uWord#") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (UWord :: Type -> Type))) |
Instances
Bounded Word8 | |
Enum Word8 | |
Eq Word8 | |
Integral Word8 | |
Num Word8 | |
Ord Word8 | |
Read Word8 | |
Real Word8 | |
Defined in GHC.Word Methods toRational :: Word8 -> Rational | |
Show Word8 | |
Ix Word8 | |
Bits Word8 | |
Defined in GHC.Word Methods (.&.) :: Word8 -> Word8 -> Word8 (.|.) :: Word8 -> Word8 -> Word8 xor :: Word8 -> Word8 -> Word8 complement :: Word8 -> Word8 shift :: Word8 -> Int -> Word8 rotate :: Word8 -> Int -> Word8 setBit :: Word8 -> Int -> Word8 clearBit :: Word8 -> Int -> Word8 complementBit :: Word8 -> Int -> Word8 testBit :: Word8 -> Int -> Bool bitSizeMaybe :: Word8 -> Maybe Int shiftL :: Word8 -> Int -> Word8 unsafeShiftL :: Word8 -> Int -> Word8 shiftR :: Word8 -> Int -> Word8 unsafeShiftR :: Word8 -> Int -> Word8 rotateL :: Word8 -> Int -> Word8 | |
FiniteBits Word8 | |
Defined in GHC.Word Methods finiteBitSize :: Word8 -> Int countLeadingZeros :: Word8 -> Int countTrailingZeros :: Word8 -> Int |
Instances
Bounded Word16 | |
Enum Word16 | |
Eq Word16 | |
Integral Word16 | |
Num Word16 | |
Ord Word16 | |
Read Word16 | |
Real Word16 | |
Defined in GHC.Word Methods toRational :: Word16 -> Rational | |
Show Word16 | |
Ix Word16 | |
Bits Word16 | |
Defined in GHC.Word Methods (.&.) :: Word16 -> Word16 -> Word16 (.|.) :: Word16 -> Word16 -> Word16 xor :: Word16 -> Word16 -> Word16 complement :: Word16 -> Word16 shift :: Word16 -> Int -> Word16 rotate :: Word16 -> Int -> Word16 setBit :: Word16 -> Int -> Word16 clearBit :: Word16 -> Int -> Word16 complementBit :: Word16 -> Int -> Word16 testBit :: Word16 -> Int -> Bool bitSizeMaybe :: Word16 -> Maybe Int shiftL :: Word16 -> Int -> Word16 unsafeShiftL :: Word16 -> Int -> Word16 shiftR :: Word16 -> Int -> Word16 unsafeShiftR :: Word16 -> Int -> Word16 rotateL :: Word16 -> Int -> Word16 | |
FiniteBits Word16 | |
Defined in GHC.Word Methods finiteBitSize :: Word16 -> Int countLeadingZeros :: Word16 -> Int countTrailingZeros :: Word16 -> Int |
Instances
Bounded Word32 | |
Enum Word32 | |
Eq Word32 | |
Integral Word32 | |
Num Word32 | |
Ord Word32 | |
Read Word32 | |
Real Word32 | |
Defined in GHC.Word Methods toRational :: Word32 -> Rational | |
Show Word32 | |
Ix Word32 | |
Bits Word32 | |
Defined in GHC.Word Methods (.&.) :: Word32 -> Word32 -> Word32 (.|.) :: Word32 -> Word32 -> Word32 xor :: Word32 -> Word32 -> Word32 complement :: Word32 -> Word32 shift :: Word32 -> Int -> Word32 rotate :: Word32 -> Int -> Word32 setBit :: Word32 -> Int -> Word32 clearBit :: Word32 -> Int -> Word32 complementBit :: Word32 -> Int -> Word32 testBit :: Word32 -> Int -> Bool bitSizeMaybe :: Word32 -> Maybe Int shiftL :: Word32 -> Int -> Word32 unsafeShiftL :: Word32 -> Int -> Word32 shiftR :: Word32 -> Int -> Word32 unsafeShiftR :: Word32 -> Int -> Word32 rotateL :: Word32 -> Int -> Word32 | |
FiniteBits Word32 | |
Defined in GHC.Word Methods finiteBitSize :: Word32 -> Int countLeadingZeros :: Word32 -> Int countTrailingZeros :: Word32 -> Int | |
UTF8 [Word32] Source # | |