utf8-light-0.4.0.1: Unicode

Portabilityportable
Stabilityprovisional
MaintainerMatt Morrow <mjm2002@gmail.com>
Safe HaskellSafe-Infered

Codec.Binary.UTF8.Light

Description

Lightweight UTF8 handling.

Synopsis

Documentation

class UTF8 a where

Instances: ByteString, String , [Word32], [Word] , [Int32], [Int]

Methods

encode :: a -> ByteString

decode :: ByteString -> a

lenUTF8 :: Word8 -> Int

Length in Word8s

lenUTF16 :: Word16 -> Int

Length in Word16s

countUTF8 :: ByteString -> [Int]

Lengths in Word8s

encodeUTF8' :: [Word32] -> [[Word8]]

Word32s not representing valid UTF8 chars are dropped.

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 ()

writeUTF8File :: UTF8 a => FilePath -> a -> IO ()

appendUTF8File :: UTF8 a => FilePath -> a -> IO ()

hGetUTF8Line :: UTF8 a => Handle -> IO a

hGetUTF8 :: UTF8 a => Handle -> Int -> IO a

Be careful that you're sure you're not chopping a UTF8 char in two!

hGetUTF8NonBlocking :: UTF8 a => Handle -> Int -> IO a

Same warning as for hGetUTF8

i2w :: Int -> Word32

w2i :: Word32 -> Int

flipUTF8 :: UTF8 a => a -> a

 ghci> putUTF8Ln $ flipUTF8 "[?np_bs!]"
 [¡sq‾bu¿]

unflipUTF8 :: UTF8 a => a -> a

 ghci> putUTF8Ln $ (unflipUTF8 . flipUTF8) "[?np_bs!]"
 [?np_bs!]

flipTab :: [(Int, Int)]

unflipTab :: [(Int, Int)]

data Int8

8-bit signed integer type

data Int16

16-bit signed integer type

data Int32

32-bit signed integer type

data Word

A Word is an unsigned integral type, with the same size as Int.

data Word8

8-bit unsigned integer type