module Addy.Internal.Char
( utf8NonAscii,
obsNoWsCtl,
wsp,
vchar,
atext,
dtext,
ctext,
ctextObs,
qtext,
qtextObs,
quotedPair,
quotedPairObs,
)
where
import Data.Char
utf8NonAscii :: Char -> Bool
utf8NonAscii :: Char -> Bool
utf8NonAscii Char
c = Char -> Int
ord Char
c Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
0xc2 Bool -> Bool -> Bool
&& Char -> Bool
isPrint Char
c
obsNoWsCtl :: Char -> Bool
obsNoWsCtl :: Char -> Bool
obsNoWsCtl = Char -> Int
ord (Char -> Int) -> (Int -> Bool) -> Char -> Bool
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Int -> Bool
forall a. (Ord a, Num a) => a -> Bool
go
where
go :: a -> Bool
go a
n =
(a
n a -> a -> Bool
forall a. Ord a => a -> a -> Bool
>= a
1 Bool -> Bool -> Bool
&& a
n a -> a -> Bool
forall a. Ord a => a -> a -> Bool
<= a
8)
Bool -> Bool -> Bool
|| a
n a -> a -> Bool
forall a. Eq a => a -> a -> Bool
== a
11
Bool -> Bool -> Bool
|| a
n a -> a -> Bool
forall a. Eq a => a -> a -> Bool
== a
12
Bool -> Bool -> Bool
|| (a
n a -> a -> Bool
forall a. Ord a => a -> a -> Bool
>= a
14 Bool -> Bool -> Bool
&& a
n a -> a -> Bool
forall a. Ord a => a -> a -> Bool
<= a
31)
Bool -> Bool -> Bool
|| a
n a -> a -> Bool
forall a. Eq a => a -> a -> Bool
== a
127
wsp :: Char -> Bool
wsp :: Char -> Bool
wsp Char
c = Char
c Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
' ' Bool -> Bool -> Bool
|| Char
c Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'\t'
vchar :: Char -> Bool
vchar :: Char -> Bool
vchar Char
c = Int -> Bool
forall a. (Ord a, Num a) => a -> Bool
vchar' (Char -> Int
ord Char
c) Bool -> Bool -> Bool
|| Char -> Bool
utf8NonAscii Char
c
where
vchar' :: a -> Bool
vchar' a
n = a
n a -> a -> Bool
forall a. Ord a => a -> a -> Bool
>= a
0x21 Bool -> Bool -> Bool
&& a
n a -> a -> Bool
forall a. Ord a => a -> a -> Bool
<= a
0x7e
atext :: Char -> Bool
atext :: Char -> Bool
atext Char
c =
Char -> Bool
isAlphaNum Char
c
Bool -> Bool -> Bool
|| Char -> Bool
utf8NonAscii Char
c
Bool -> Bool -> Bool
|| Char
c Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'!'
Bool -> Bool -> Bool
|| Char
c Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'#'
Bool -> Bool -> Bool
|| Char
c Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'$'
Bool -> Bool -> Bool
|| Char
c Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'%'
Bool -> Bool -> Bool
|| Char
c Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'&'
Bool -> Bool -> Bool
|| Char
c Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'\''
Bool -> Bool -> Bool
|| Char
c Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'*'
Bool -> Bool -> Bool
|| Char
c Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'+'
Bool -> Bool -> Bool
|| Char
c Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'-'
Bool -> Bool -> Bool
|| Char
c Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'/'
Bool -> Bool -> Bool
|| Char
c Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'='
Bool -> Bool -> Bool
|| Char
c Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'?'
Bool -> Bool -> Bool
|| Char
c Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'^'
Bool -> Bool -> Bool
|| Char
c Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'_'
Bool -> Bool -> Bool
|| Char
c Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'`'
Bool -> Bool -> Bool
|| Char
c Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'{'
Bool -> Bool -> Bool
|| Char
c Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'|'
Bool -> Bool -> Bool
|| Char
c Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'}'
Bool -> Bool -> Bool
|| Char
c Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'~'
dtext :: Char -> Bool
dtext :: Char -> Bool
dtext Char
c = Int -> Bool
forall a. (Ord a, Num a) => a -> Bool
asciidtext (Char -> Int
ord Char
c) Bool -> Bool -> Bool
|| Char -> Bool
utf8NonAscii Char
c
where
asciidtext :: a -> Bool
asciidtext a
n =
(a
n a -> a -> Bool
forall a. Ord a => a -> a -> Bool
>= a
33 Bool -> Bool -> Bool
&& a
n a -> a -> Bool
forall a. Ord a => a -> a -> Bool
<= a
90)
Bool -> Bool -> Bool
|| (a
n a -> a -> Bool
forall a. Ord a => a -> a -> Bool
>= a
94 Bool -> Bool -> Bool
&& a
n a -> a -> Bool
forall a. Ord a => a -> a -> Bool
<= a
126)
ctext :: Char -> Bool
ctext :: Char -> Bool
ctext Char
c = Int -> Bool
forall a. (Ord a, Num a) => a -> Bool
asciictext (Char -> Int
ord Char
c) Bool -> Bool -> Bool
|| Char -> Bool
utf8NonAscii Char
c
where
asciictext :: a -> Bool
asciictext a
n =
(a
n a -> a -> Bool
forall a. Ord a => a -> a -> Bool
>= a
33 Bool -> Bool -> Bool
&& a
n a -> a -> Bool
forall a. Ord a => a -> a -> Bool
<= a
39)
Bool -> Bool -> Bool
|| (a
n a -> a -> Bool
forall a. Ord a => a -> a -> Bool
>= a
42 Bool -> Bool -> Bool
&& a
n a -> a -> Bool
forall a. Ord a => a -> a -> Bool
<= a
91)
Bool -> Bool -> Bool
|| (a
n a -> a -> Bool
forall a. Ord a => a -> a -> Bool
>= a
93 Bool -> Bool -> Bool
&& a
n a -> a -> Bool
forall a. Ord a => a -> a -> Bool
<= a
126)
ctextObs :: Char -> Bool
ctextObs :: Char -> Bool
ctextObs = Char -> Bool
obsNoWsCtl
qtext :: Char -> Bool
qtext :: Char -> Bool
qtext Char
c = Int -> Bool
forall a. (Num a, Ord a) => a -> Bool
asciiqtext (Char -> Int
ord Char
c) Bool -> Bool -> Bool
|| Char -> Bool
utf8NonAscii Char
c
where
asciiqtext :: a -> Bool
asciiqtext a
n =
a
n a -> a -> Bool
forall a. Eq a => a -> a -> Bool
== a
33
Bool -> Bool -> Bool
|| (a
n a -> a -> Bool
forall a. Ord a => a -> a -> Bool
>= a
35 Bool -> Bool -> Bool
&& a
n a -> a -> Bool
forall a. Ord a => a -> a -> Bool
<= a
91)
Bool -> Bool -> Bool
|| (a
n a -> a -> Bool
forall a. Ord a => a -> a -> Bool
>= a
93 Bool -> Bool -> Bool
&& a
n a -> a -> Bool
forall a. Ord a => a -> a -> Bool
<= a
126)
qtextObs :: Char -> Bool
qtextObs :: Char -> Bool
qtextObs = Char -> Bool
obsNoWsCtl
quotedPair :: Char -> Bool
quotedPair :: Char -> Bool
quotedPair Char
c = Char -> Bool
vchar Char
c Bool -> Bool -> Bool
|| Char -> Bool
wsp Char
c
quotedPairObs :: Char -> Bool
quotedPairObs :: Char -> Bool
quotedPairObs Char
c =
Char -> Bool
obsNoWsCtl Char
c
Bool -> Bool -> Bool
|| Char
c Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'\r'
Bool -> Bool -> Bool
|| Char
c Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'\n'
Bool -> Bool -> Bool
|| Char
c Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'\0'