I use Haskell to program the parser, but this error is a wall that I cannot get through. Here is my code:
main = do
arguments <- getArgs
let fileName = head arguments
fileContents <- readFile fileName
converter <- open "UTF-8" Nothing
let titleLength = length fileName
titleWithoutExtension = take (titleLength - 4) fileName
allNonEmptyLines = unlines $ tail $ filter (/= "") $ lines fileContents
When I try to read a file encoded with "US-ASCII", I get a known hGetContents error: invalid argument (invalid byte sequence). I tried changing "UTF-8" in my code to "US-ASCII", but the error persists. Is there any way to read these files or any problems with file encoding?
source
share