Skip to content

Instantly share code, notes, and snippets.

@qoelet
Created July 30, 2013 09:05
Show Gist options
  • Save qoelet/6111430 to your computer and use it in GitHub Desktop.
Save qoelet/6111430 to your computer and use it in GitHub Desktop.
null character cleanup
-- 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