summaryrefslogtreecommitdiffstats
path: root/Codec
diff options
context:
space:
mode:
authorSigbjorn Finne <sof@galois.com>2008-09-14 11:00:32 -0700
committerSigbjorn Finne <sof@galois.com>2008-09-14 11:00:32 -0700
commit7567f36fdfc9f6416bba4db23e4f9bbdcf874dff (patch)
tree1123ce38bcb92db82152adf81f277d9ba6bb437b /Codec
parent41a85f826ce15708d93c0cc9095ac778a80060b6 (diff)
encode: simplified
Diffstat (limited to 'Codec')
-rw-r--r--Codec/MIME/QuotedPrintable.hs15
1 files changed, 7 insertions, 8 deletions
diff --git a/Codec/MIME/QuotedPrintable.hs b/Codec/MIME/QuotedPrintable.hs
index 72fbaa6..a6dc99a 100644
--- a/Codec/MIME/QuotedPrintable.hs
+++ b/Codec/MIME/QuotedPrintable.hs
@@ -40,17 +40,16 @@ encode xs = encodeLength 0 xs
encodeLength :: Int -> String -> String
encodeLength _ "" = ""
+encodeLength n (x:xs)
+ | n >= 72 = '=':'\r':'\n':encodeLength 0 (x:xs)
encodeLength n ('=':xs)
- | n <= 72 = '=':'3':'D':encodeLength (n+3) xs
- | otherwise = '=':'\r':'\n': encodeLength 0 ('=':xs)
+ = '=':'3':'D':encodeLength 0 xs
encodeLength n (x:xs)
- | n >= 75 = '=':'\r':'\n':encodeLength 0 (x:xs)
- | ox >= 0x21 && ox <= 0x7e = x : encodeLength (n+1) xs
- | (ox == 0x09 || ox == 0x20) && n < 74 = x : encodeLength (n+1) xs
| ox >= 0x100 = error ("QuotedPrintable.encode: encountered > 8 bit character: " ++ show (x,ox))
-
- | n <= 72 = '=':showH (ox `div` 16) : showH (ox `mod` 16) : encodeLength (n+3) xs
- | otherwise = '=':'\r':'\n':encodeLength 0 (x:xs)
+ | n >= 72 = '=':'\r':'\n':encodeLength 0 (x:xs)
+ | ox >= 0x21 && ox <= 0x7e = x : encodeLength (n+1) xs
+ | ox == 0x09 || ox == 0x20 = x : encodeLength (n+1) xs
+ | otherwise = '=':'\r':'\n':encodeLength 0 (x:xs)
where
ox = ord x
showH v