diff options
Diffstat (limited to 'src/Data/ByteString/Base32.hs')
-rw-r--r-- | src/Data/ByteString/Base32.hs | 20 |
1 files changed, 1 insertions, 19 deletions
diff --git a/src/Data/ByteString/Base32.hs b/src/Data/ByteString/Base32.hs index e9ac3ee..0568c54 100644 --- a/src/Data/ByteString/Base32.hs +++ b/src/Data/ByteString/Base32.hs | |||
@@ -21,7 +21,6 @@ module Data.ByteString.Base32 | |||
21 | ) where | 21 | ) where |
22 | 22 | ||
23 | import Data.ByteString as BS | 23 | import Data.ByteString as BS |
24 | import Data.ByteString.Internal as BS | ||
25 | import Data.ByteString.Base32.Internal | 24 | import Data.ByteString.Base32.Internal |
26 | import Data.List as L | 25 | import Data.List as L |
27 | 26 | ||
@@ -60,23 +59,6 @@ decTable = BS.pack $ L.map decW5 [minBound .. maxBound] | |||
60 | decode :: Base32 -> ByteString | 59 | decode :: Base32 -> ByteString |
61 | decode = pack5 decTable | 60 | decode = pack5 decTable |
62 | 61 | ||
63 | decCharLenient :: Char -> Word5 | ||
64 | decCharLenient x | ||
65 | | x < '2' = err | ||
66 | | x <= '7' = 26 + fromIntegral (fromEnum x) - fromIntegral (fromEnum '2') | ||
67 | | x < 'A' = err | ||
68 | | x <= 'Z' = fromIntegral (fromEnum x) - fromIntegral (fromEnum 'A') | ||
69 | | x < 'a' = err | ||
70 | | x <= 'z' = fromIntegral (fromEnum x) - fromIntegral (fromEnum 'a') | ||
71 | | otherwise = err | ||
72 | where | ||
73 | err = error "base32: decodeChar: out of range" | ||
74 | |||
75 | decW5Lenient :: Word8 -> Word5 | ||
76 | decW5Lenient = decCharLenient . w2c | ||
77 | {-# INLINE decW5Lenient #-} | ||
78 | |||
79 | -- TODO padding leniency | ||
80 | -- | Case-insensitive counterpart of the 'decode'. | 62 | -- | Case-insensitive counterpart of the 'decode'. |
81 | decodeLenient :: Base32 -> ByteString | 63 | decodeLenient :: Base32 -> ByteString |
82 | decodeLenient = id -- pack5 nullPtr decW5Lenient \ No newline at end of file | 64 | decodeLenient = pack5Lenient decTable \ No newline at end of file |