From 13dc0f086d3d8f217a2818a429ac117c97397e9b Mon Sep 17 00:00:00 2001 From: Sam T Date: Thu, 26 Sep 2013 22:39:29 +0400 Subject: Make decode case insensitive. > 6. Base 32 Encoding > > The Base 32 encoding is designed to represent arbitrary sequences of > octets in a form that _needs to be case insensitive_ but that need not > be human readable. --- src/Data/ByteString/Base32.hs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/Data/ByteString/Base32.hs b/src/Data/ByteString/Base32.hs index 5dc025c..a5835ad 100644 --- a/src/Data/ByteString/Base32.hs +++ b/src/Data/ByteString/Base32.hs @@ -227,11 +227,13 @@ pack5 !tbl bs @ (PS fptr off sz) = decW5 :: Word8 -> Word5 decW5 !x - | x < 50 {- c2w '2' -} = invIx - | x <= 55 {- c2w '7' -} = x - 24 - | x < 65 {- c2w 'A' -} = invIx - | x <= 90 {- c2w 'Z' -} = x - 65 - | otherwise = invIx + | x < 50 {- c2w '2' -} = invIx + | x <= 55 {- c2w '7' -} = x - 24 {- c2w '2' - 26 -} + | x < 65 {- c2w 'A' -} = invIx + | x <= 90 {- c2w 'Z' -} = x - 65 {- c2w 'A' -} + | x < 97 {- c2w 'a' -} = invIx + | x <= 122 {- c2w 'z' -} = x - 97 {- c2w 'a' -} + | otherwise = invIx {-# INLINE decW5 #-} decTable :: ForeignPtr Word8 -- cgit v1.2.3