Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
15
Task/URL-decoding/Haskell/url-decoding-1.hs
Normal file
15
Task/URL-decoding/Haskell/url-decoding-1.hs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
import qualified Data.Char as Char
|
||||
|
||||
urlDecode :: String -> Maybe String
|
||||
urlDecode [] = Just []
|
||||
urlDecode ('%':xs) =
|
||||
case xs of
|
||||
(a:b:xss) ->
|
||||
urlDecode xss
|
||||
>>= return . ((Char.chr . read $ "0x" ++ [a,b]) :)
|
||||
_ -> Nothing
|
||||
urlDecode ('+':xs) = urlDecode xs >>= return . (' ' :)
|
||||
urlDecode (x:xs) = urlDecode xs >>= return . (x :)
|
||||
|
||||
main :: IO ()
|
||||
main = putStrLn . maybe "Bad decode" id $ urlDecode "http%3A%2F%2Ffoo%20bar%2F"
|
||||
Loading…
Add table
Add a link
Reference in a new issue