module Unicode.Char
( unicodeVersion
, module Unicode.Char.General
, module Unicode.Char.General.Compat
, module Unicode.Char.Case
, module Unicode.Char.Case.Compat
, module Unicode.Char.Numeric
, module Unicode.Char.Normalization
, module Unicode.Char.Identifiers
, showCodePoint
, ord
, chr
)
where
import Data.Char (chr, ord)
import Unicode.Char.Case hiding (Unfold(..), Step(..))
import Unicode.Char.Case.Compat
import Unicode.Char.General hiding (isAlphaNum)
import Unicode.Char.General.Compat
import Unicode.Char.Identifiers
import Unicode.Char.Numeric
import Unicode.Char.Normalization
import Unicode.Internal.Char.Version (unicodeVersion)
showCodePoint :: Char -> ShowS
showCodePoint :: Char -> ShowS
showCodePoint Char
c = ShowS
pad ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int, Int) -> ShowS
showIt (Int -> Int -> (Int, Int)
forall a. Integral a => a -> a -> (a, a)
quotRem Int
cp Int
16)
where
cp :: Int
cp = Char -> Int
ord Char
c
pad :: ShowS
pad | Int
cp Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
0x00f = \[Char]
s -> Char
'0' Char -> ShowS
forall a. a -> [a] -> [a]
: Char
'0' Char -> ShowS
forall a. a -> [a] -> [a]
: Char
'0' Char -> ShowS
forall a. a -> [a] -> [a]
: [Char]
s
| Int
cp Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
0x0ff = \[Char]
s -> Char
'0' Char -> ShowS
forall a. a -> [a] -> [a]
: Char
'0' Char -> ShowS
forall a. a -> [a] -> [a]
: [Char]
s
| Int
cp Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
0xfff = (Char
'0' Char -> ShowS
forall a. a -> [a] -> [a]
:)
| Bool
otherwise = ShowS
forall a. a -> a
id
showIt :: (Int, Int) -> ShowS
showIt (Int
n, Int
d) [Char]
r = case Int -> Char
intToDigiT Int
d of
!Char
c' -> case Int
n of
Int
0 -> Char
c' Char -> ShowS
forall a. a -> [a] -> [a]
: [Char]
r
Int
_ -> (Int, Int) -> ShowS
showIt (Int -> Int -> (Int, Int)
forall a. Integral a => a -> a -> (a, a)
quotRem Int
n Int
16) (Char
c' Char -> ShowS
forall a. a -> [a] -> [a]
: [Char]
r)