| Copyright | (c) Matt Morrow 2008 Francesco Ariis 2022 |
|---|---|
| License | BSD3 |
| Maintainer | Francesco Ariis <fa-ml@ariis.it> |
| Stability | provisional |
| Portability | portable |
| Safe Haskell | None |
| Language | Haskell2010 |
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
- 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
- c2w :: Char -> Word32
- w2c :: Word32 -> Char
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
| PrintfArg Int8 | |
Defined in Text.Printf | |
| Bits Int8 | |
Defined in GHC.Internal.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.Internal.Int Methods finiteBitSize :: Int8 -> Int countLeadingZeros :: Int8 -> Int countTrailingZeros :: Int8 -> Int | |
| Bounded Int8 | |
Defined in GHC.Internal.Int | |
| Enum Int8 | |
| Ix Int8 | |
| Num Int8 | |
| Read Int8 | |
Defined in GHC.Internal.Int | |
| Integral Int8 | |
| Real Int8 | |
Defined in GHC.Internal.Int Methods toRational :: Int8 -> Rational | |
| Show Int8 | |
| Eq Int8 | |
| Ord Int8 | |
Instances
| PrintfArg Int16 | |
Defined in Text.Printf | |
| Bits Int16 | |
Defined in GHC.Internal.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.Internal.Int Methods finiteBitSize :: Int16 -> Int countLeadingZeros :: Int16 -> Int countTrailingZeros :: Int16 -> Int | |
| Bounded Int16 | |
Defined in GHC.Internal.Int | |
| Enum Int16 | |
| Ix Int16 | |
| Num Int16 | |
| Read Int16 | |
Defined in GHC.Internal.Int | |
| Integral Int16 | |
| Real Int16 | |
Defined in GHC.Internal.Int Methods toRational :: Int16 -> Rational | |
| Show Int16 | |
| Eq Int16 | |
| Ord Int16 | |
Instances
Instances
| PrintfArg Word | |
Defined in Text.Printf | |
| Bits Word | |
Defined in GHC.Internal.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 GHC.Internal.Bits Methods finiteBitSize :: Word -> Int countLeadingZeros :: Word -> Int countTrailingZeros :: Word -> Int | |
| Bounded Word | |
Defined in GHC.Internal.Enum | |
| Enum Word | |
| Num Word | |
| Integral Word | |
| Real Word | |
Defined in GHC.Internal.Real Methods toRational :: Word -> Rational | |
| Eq Word | |
| Ord Word | |
| Foldable (UWord :: Type -> Type) | |
Defined in GHC.Internal.Data.Foldable Methods fold :: Monoid m => UWord m -> m foldMap :: Monoid m => (a -> m) -> UWord a -> m foldMap' :: Monoid m => (a -> m) -> UWord a -> m foldr :: (a -> b -> b) -> b -> UWord a -> b foldr' :: (a -> b -> b) -> b -> UWord a -> b foldl :: (b -> a -> b) -> b -> UWord a -> b foldl' :: (b -> a -> b) -> b -> UWord a -> b foldr1 :: (a -> a -> a) -> UWord a -> a foldl1 :: (a -> a -> a) -> UWord a -> a toList :: UWord a -> [a] null :: UWord a -> Bool length :: UWord a -> Int elem :: Eq a => a -> UWord a -> Bool maximum :: Ord a => UWord a -> a minimum :: Ord a => UWord a -> a sum :: Num a => UWord a -> a product :: Num a => UWord a -> a | |
| UTF8 [Word] Source # | |
Instances
| PrintfArg Word8 | |
Defined in Text.Printf | |
| Bits Word8 | |
Defined in GHC.Internal.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.Internal.Word Methods finiteBitSize :: Word8 -> Int countLeadingZeros :: Word8 -> Int countTrailingZeros :: Word8 -> Int | |
| Bounded Word8 | |
Defined in GHC.Internal.Word | |
| Enum Word8 | |
| Ix Word8 | |
| Num Word8 | |
| Integral Word8 | |
| Real Word8 | |
Defined in GHC.Internal.Word Methods toRational :: Word8 -> Rational | |
| Show Word8 | |
| Eq Word8 | |
| Ord Word8 | |