Created
July 30, 2013 09:05
-
-
Save qoelet/6111430 to your computer and use it in GitHub Desktop.
null character cleanup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- file: Clean.hs | |
-- removes null characters | |
import System.Environment (getArgs) | |
removeNull :: [Char] -> [Char] | |
removeNull [] = [] | |
removeNull (x:xs) | |
| x == '\000' = [] ++ removeNull xs | |
| otherwise = [x] ++ removeNull xs | |
readWriteFile function inputFile outputFile = do | |
input <- readFile inputFile | |
writeFile outputFile (function input) | |
main = mainWith removeNull | |
where mainWith function = do | |
args <- getArgs | |
case args of | |
[input, output] -> readWriteFile removeNull input output | |
_ -> putStrLn "usage hint: ./Clean <input file> <output file>\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment